Downloading files?
| From: | (Alex Elderson) | Date: | Tue, 02 Jul 2002 12:59:00 +0000 |
| Subject: | Downloading files? | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-14525@lists.php.net to get a copy of this message | ||
Hi,
I have made a php script ware you can download some files, but it doesn't
work very well
After the first "echo fread($fc, 10240);" line it will send some strange
data
what to do?
if (!($fc = fopen($path . $file, "rb"))) {
echo "error\n";
exit;
}
$file_size = filesize($path . $file);
ob_end_clean();
ignore_user_abort(false);
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')){
// IE cannot download from sessions without a cache
header('Cache-Control: public');
}
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment;
filename=\"".$file."\"");
header("Content-length: ".(string)($file_size));
if ($description!="") {
header("Content-Description: " . $description);
}
while(!feof($fc)) {
set_time_limit(5);
echo fread($fc, 10240);
flush();
}
fclose($fc);
exit;