Good morning folks,
I have created a file transfer application for a client that has been giving me some grief. The problem is that file downloads are ending prematurely which appears to be a result of the maximum execution time setting on the host. I have attempted to use the “set_time_limit” function to prevent the transfers from timing out without success. I suspect that I cannot override this setting on the host and they won’t change the time duration from it’s current setting (5 minutes).
Can anybody recommend an approach that doesn’t run into this time limit? I should also mention that I need to be able to assign a name for the file prior to download because the files aren’t saved under their real name, they are saved with a date and time stamp appended to the filename. I do this to prevent a file from overwriting an earlier version of the same file already on the server, hence the $filename variable in the script. Any suggestions would be greatly appreciated.
Here is the code I use for the download function, less some of the cases under the $ext switch for simplicity.
$filename = mysql_result($filesResult,0,"filename");
$path = 'files/';
$fullpath = $path . $filename;
$ext = mysql_result($filesResult,0,"ext");
$ext = strtolower($ext);
if(isset($_SESSION['valid_UID'])){
switch ($action) {
case "dl":
$bytes = filesize($fullpath);
switch ($ext) {
case "jpg":
header("Content-type: image/jpeg");
break;
case "mpg":
header("Content-type: video/mpeg");
break;
default:
header("Content-type: application/octet-stream");
break;
}
header("Content-disposition: attachment; filename=\"$shortname\"");
header("Content-length: $bytes");
set_time_limit(14400);
@readfile($fullpath);