<?php
// public_html/api/debug-path.php

$target = '/home/jiliapii/casheco_core/storage/app/public/banners/xXmahIoCdUYvNbnTsEpHL5Z62rW3TAScZtsFy5Ac.jpg';

echo "<h3>Casheco Storage Debugger</h3>";
echo "<b>Checking Path:</b> " . $target . "<br>";

if (file_exists($target)) {
    echo "<span style='color:green'>âœ… SUCCESS: File exists and is readable!</span><br>";
    echo "<b>Permissions:</b> " . substr(sprintf('%o', fileperms($target)), -4) . "<br>";
    echo "<b>Mime Type:</b> " . mime_content_type($target) . "<br>";
} else {
    echo "<span style='color:red'>âŒ ERROR: File not found at this origin path.</span><br>";
    echo "<b>Parent folder exists?</b> " . (is_dir(dirname($target)) ? 'Yes' : 'No') . "<br>";
}

// Check if a physical storage folder is blocking the route
if (is_dir(__DIR__ . '/storage')) {
    echo "<br><span style='color:orange'>âš ï¸ WARNING: A physical 'storage' folder exists in public_html/api/. This will block your Laravel route!</span>";
}