开发者

How do I prevent a Request Timeout when uploading a file in PHP?

I'm getting a pretty consistent timeout after 90 seconds. I followed this guide to fix the problem and changed my PHP settings to 600 for timeouts and 20M for file sizes.

In my scenario, I am uploading images. A 100k image seems to upload without any problems but 500k image files time out after 90 seconds.

Any ideas o开发者_如何学编程n what I can check next?

If not could anyone suggest a good alternative for single file uploads.

Thanks.


Edit 1:

I did some more tests and I cannot upload files over 200kb on any site.

It seems that it may have something to do with my OS (Windows 7 RC2). My girlfriend is on Vista and it works without a problem and I have an XP virtual machine installed which also works.


I would not have expected your PHP script to be called until the upload has completed, so this is probably a web server config issue.

To verify if your script is being executed at all in the problem cases, trying writing to a log file on disk right at the start of your script and see if this is happening. If it is, you know the problem is with your script. If not, you know it is a web server issue.


Add a call to set_time_limit() at the top of your PHP script to specify a script timeout of more than 90 seconds.


set_time_limit(0);

It allow a infinite time_limit.


I did some more tests and I cannot upload files over 200kb on any site.

It seems that it may have something to do with my OS (Windows 7 RC2). My girlfriend is on Vista and it works without a problem and I have an XP virtual machine installed which also works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜