can file uploads time out in php

can file uploads time out in php  using -'php,upload'

Hi im quite new to PHP, i have created a form for very large csv files to be uploaded to my server. Some one mentioned to me that the browser can time out due to the uploading file being to big, is this true? and if so, can it be prevented?

Thanks for your help!

asked Sep 29, 2015 by shikhar jain
0 votes

10 Answers

0 votes

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
answered Sep 29, 2015 by tseetha
0 votes

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


  • 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.


  • 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.

answered Sep 29, 2015 by deepak07.s
0 votes

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.

answered Sep 29, 2015 by amit.gupta
0 votes

When uploading very large files, you have to change 4 configuration variables:

  • upload_max_filesize
  • post_max_size
  • memory_limit
  • time_limit

Time limit may be increased at runtime with set_time_limit().

answered Sep 29, 2015 by mannar kande
0 votes

A script is allowed to run, by default, for something like 30 seconds. You can use the set_time_limit() function to alter this. Also, if your user will need to upload large files, you'll need to change the post_max_size and/or the upload_max_filesize values in your php.ini file.

Also, if you want to just extend your timeout limit globally, you can change max-execution-time in php.ini.

answered Sep 29, 2015 by bhavin
0 votes

It's not just timeouts that can cause problems. There are some limits on the maximum size of file that can be uploaded. These limits can be changed in the php.ini file:

upload_max_filesize memory_limit

Check out for details.

answered Sep 29, 2015 by mannar kande
0 votes

Yes it is true. File upload is done through a POST request and requests in general are subject to timeout. You should be able to reconfigure your environment for a longer request timeout.

answered Sep 29, 2015 by deepak gupta
0 votes

Does the PHP download has the same problem?

I tried to use PHP copy() function to get a large amount data--a lot of files about 5 to 6 K each. It seems I can not copy them all at a time.

answered Sep 29, 2015 by atulpariharmca
0 votes

My answer is not directly related to your original question, but if you have a reverse proxy load balancer in front of your PHP script, the load balancer can timeout or block large uploads. Always check your load balancer's configuration if you support file uploads. Just like PHP, most load balancers default settings for uploads are pretty small.

answered Sep 29, 2015 by mca.agarwal
0 votes

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
answered Sep 29, 2015 by sandeep bhadauria