Files
html/api/img.php
2026-04-12 22:57:03 +02:00

11 lines
487 B
PHP

<?php
$name = basename($_GET["n"] ?? "");
$path = "/var/www/html/images/$name";
if ($name && file_exists($path)) {
$ext = pathinfo($name, PATHINFO_EXTENSION);
$types = ["png"=>"image/png","jpg"=>"image/jpeg","gif"=>"image/gif","svg"=>"image/svg+xml","webp"=>"image/webp"];
header("Content-Type: " . ($types[$ext] ?? "application/octet-stream"));
header("Cache-Control: public, max-age=2592000");
readfile($path);
} else { http_response_code(404); echo "Not found"; }