diff options
| author | Michael Walker <mike@barrucadu.co.uk> | 2015-09-23 01:27:35 +0100 |
|---|---|---|
| committer | Michael Walker <mike@barrucadu.co.uk> | 2015-09-23 01:27:35 +0100 |
| commit | 528bf314f3c9ee056ec8dcd8a37e98740ee53173 (patch) | |
| tree | a31850d77954beb86d9790a7cc0d0014924128fe /b.php | |
| parent | 6d20e7bfb2536b154541eb6e6f3df93ed83437dd (diff) | |
| parent | 9679f970cbfcd839f61466533788eb6afe033ca1 (diff) | |
Merge pull request #34 from AshtonHarding/master
fixed stream spit | tested on home-server, works fine.
Diffstat (limited to 'b.php')
| -rwxr-xr-x | b.php | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -4,17 +4,18 @@ $dir = "banners/"; $files = scandir($dir); $images = array_diff($files, array('.', '..')); $name = $images[array_rand($images)]; -// open the file in a binary mode -$fp = fopen($dir . $name, 'rb'); + +// snags the extension +$img_extension = pathinfo($name, PATHINFO_EXTENSION); // send the right headers header('Cache-Control: no-cache, no-store, must-revalidate'); // HTTP 1.1 header('Pragma: no-cache'); // HTTP 1.0 header('Expires: 0'); // Proxies -header('Content-Type: ' . $fp['type']); -header('Content-Length: ' . $fp['bytes']); +header("Content-type: image/" . $img_extension); +header("Content-Disposition: inline; filename=" . $name); -// dump the picture and stop the script -fpassthru($fp); +// readfile displays the image, passthru seems to spits stream. +readfile($dir.$name); exit; ?> |
