fixed stream spit | tested on home-server, works fine.
This commit is contained in:
parent
686a9eed56
commit
f3c8f0248e
13
b.php
13
b.php
@ -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;
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user