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
Download stopped in the middle
Moderator: General Moderators
-
ericng0311
- Forum Newbie
- Posts: 4
- Joined: Fri Mar 12, 2004 7:06 pm
- Location: BC, Canada
-
TheBentinel.com
- Forum Contributor
- Posts: 282
- Joined: Wed Mar 10, 2004 1:52 pm
- Location: Columbus, Ohio
Re: Download stopped in the middle
What happens if you leave off the Content-Length header? Does it still stop downloading after that much time?ericng0311 wrote: header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($file));
And can you successfully download small files, just not big ones?
-
ericng0311
- Forum Newbie
- Posts: 4
- Joined: Fri Mar 12, 2004 7:06 pm
- Location: BC, Canada
-
TheBentinel.com
- Forum Contributor
- Posts: 282
- Joined: Wed Mar 10, 2004 1:52 pm
- Location: Columbus, Ohio
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.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
-
ericng0311
- Forum Newbie
- Posts: 4
- Joined: Fri Mar 12, 2004 7:06 pm
- Location: BC, Canada
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
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