Can file uploads time out in PHP?

There are some configuration directives that can cause large uploads to fail if their values are too small:

PHP

  • max_input_time   Maximum time in seconds a script is allowed to parse input data, like POST, GET and file uploads
  • upload_max_filesize   Maximum size of an uploaded file.
  • post_max_size   Maximum size of post data allowed.

Apache

  • TimeOut   Amount of time the server will wait for certain events before failing a request
  • LimitRequestBody   Restricts the total size of the HTTP request body sent from the client

There are probably some more than this.


You need a proper value for the following php.ini settings:

  1. max_input_time (not max_execution_time!)
  2. upload_max_filesize
  3. post_max_size

and maybe

  1. memory_limit

A good way to work around the poor handling of large file uploads in php, is to use an uploader like JUpload which will split the file into chunks before sending them. This also has the benefit for your users that they get a proper progress feedback while uploading, and they can upload multiple files in one go.


I was able solve this problem using the following settings, you could use different values but you get the idea:

For my server, I put these lines in a ".user.ini" file inside the script directory, your server may look for a different file, if you do a phpinfo('user_ini.filename') on the server it will spit out the file you need to put your values in

max_execution_time = 1800
max_input_time = -1
post_max_size = 100M
upload_max_filesize = 100M
memory_limit = 256M

Tags:

Php

Upload