Download interrupted after around 5 min.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Cezar
Forum Newbie
Posts: 5
Joined: Tue Oct 12, 2004 8:21 am

Download interrupted after around 5 min.

Post by Cezar »

twigletmac | Help us, help you. Please use

Code: Select all

and

Code: 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(); 
} 

?>
Thanks for any suggestions.
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

what is your max_execution_time set to in your php configuration?
Post Reply