Page 1 of 1

Download stopped in the middle

Posted: Fri Mar 12, 2004 7:06 pm
by ericng0311
Hi everyone,

This is the script I wrote to download files form the server:

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-type: application/x-download");
header("Content-Disposition: attachment; filename=".basename($file).";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($file));
readfile("$file");
exit();

For some reasons, the file transfer will stop after 4mins and 54secs ~ 59secs, so any bigger files that need more that this time to download cannot be completed.

I am not sure if it's a server setting problem or a coding problem. I am using windowsXP, IIS 5.1 and PHP 5

Thank you very much.


Eric

Re: Download stopped in the middle

Posted: Fri Mar 12, 2004 8:14 pm
by TheBentinel.com
ericng0311 wrote: header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($file));
What happens if you leave off the Content-Length header? Does it still stop downloading after that much time?

And can you successfully download small files, just not big ones?

Posted: Mon Mar 15, 2004 2:57 pm
by ericng0311
Hi Dave,

I tried take out the Content-length header, but still the download stopped at around 5 minutes. Yes, any small files that takes less than 5 minutes to download works fine.

Any idea?

Thank you very much for your help

Eric

Posted: Mon Mar 15, 2004 3:05 pm
by TheBentinel.com
ericng0311 wrote:Hi Dave,

I tried take out the Content-length header, but still the download stopped at around 5 minutes. Yes, any small files that takes less than 5 minutes to download works fine.

Any idea?

Thank you very much for your help

Eric
Can you download the file without using your script? What if you just put it on your server and create a link to it, then try to download it? If it still fails after 5 minutes, then you know it's a problem with your web server or client, not your PHP setup.

Posted: Mon Mar 15, 2004 3:48 pm
by ericng0311
Yes, I can download any files without any problem if I am not using the PHP script. So there must be something wrong with the script or my php.ini setting. But I didn't change anything on the php.ini, I keep all default settings.

Since I want the users to download PDF files instead of open it in the browser, coz they are very big (up to 100MB). That's why I worte this script.

any suggestion?

Thanks again

Eirc