dtcpvz8162
dtcpvz8162
2009-10-08 08:50

在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 on 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.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • douou5933 douou5933 12年前

    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.

    点赞 评论 复制链接分享
  • douhuan5073 douhuan5073 12年前
    set_time_limit(0);
    

    It allow a infinite time_limit.

    点赞 评论 复制链接分享
  • duanlao1552 duanlao1552 12年前

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

    点赞 评论 复制链接分享
  • doulu1945 doulu1945 12年前

    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.

    点赞 评论 复制链接分享

为你推荐