I'm currently trying to get a small script working on my server, the point would be to serve a random PNG at a certain adress, for example https://domain.me/image/.
In /image/, I have this index.php, that does the job pretty well and outputs what I want:
<?php
$max = 30;
$image = rand(1, $max);
$name = '/var/www/image/src/'.$image.'.png';
$fp = fopen($name, 'rb');
header("Content-Type: image/png");
header("Content-Length: " . filesize($name));
fpassthru($fp);
exit;
?>
(my PNGs are as you guessed stored in /image/src/)
I'm now trying to run that script when someone calls https://domain.me/image/script.png (some websites require a PNG extension at the end of the URL), and can't really figure out how to proceed.