Download interrupted after around 5 min.
Posted: Tue Oct 12, 2004 8:31 am
twigletmac | Help us, help you. Please use
Thanks for any suggestions.
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hello everybody!
I have a problem with downloading big files (e.g 50 MB) using PHP coding; after around 5 min. from the start the download is interrupted and the file cannot be used.
The code used to download the file is listed below:Code: Select all
<?php
$filename = $_GET['filename'];
$filename=rawurldecode($filename);
if(!$filename){ echo "ERROR: No filename specified. Please try again."; }
else {
// fix for IE catching or PHP bug issue
header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
// browser must download file from server instead of cache
// force download dialog
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
// use the Content-Disposition header to supply a recommended filename and
// force the browser to display the save dialog.
header("Content-Disposition: attachment; filename=".basename($filename).";");
header("Content-Transfer-Encoding: binary");
readfile($filename);
exit();
}
?>