diff options
| author | lolicon <lolicon@teknik.io> | 2015-09-19 09:50:50 -0500 |
|---|---|---|
| committer | lolicon <lolicon@teknik.io> | 2015-09-19 09:50:50 -0500 |
| commit | f3c8f0248ec675613c8ad80057fcc10e868a11cd (patch) | |
| tree | e6a11921430aca426c4572640d39dc758c546046 /b.php | |
| parent | 686a9eed5686428e5ac65ce991933e8afd62c3aa (diff) | |
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: " . $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; ?> |
