My PHP web application requires files (about 2.5 to 3 GB in size) to be uploaded to the server. How will this impact on following directives ?

what are the required values in my case?

  • post_max_size
  • upload_max_filesize
  • memory_limit

Your help will greatly be appreciated.


Are you using 32bit or 64bit PHP?

Written by binaryLV

i am running 32 bit system (Fedora14)

Written by Bishwo

If your dealing with files that big, you should use FTP to transfer the file. The bigger the file, the more time it requires to send the file. Sometimes the connection can be reset causing the transfer to fail. Something to think about

Written by Colum

About memory_limit - I've read that it has to be set to larger value, if large files need to be uploaded, though, when testing, I saw that files are instantly saved to temporary directory (rather than memory), so memory_limit was not a problem.

Written by binaryLV

@colum first i need to transfer the file to the webserver. for that i am using ajax upload. secondly, i need to transfer the file to another linux server. i am using PHP-SSH2 for this. I am not facing any connection timeout problem

Written by Bishwo

About post_max_size and upload_max_filesize - I might be wrong, but they might be limited to 2GB on 32bit systems. This should be tested. If there is such limit, workaround would be disabling them completely. You might also be interested in configuring max_input_time, though I don't think that there should be problems because of it.

Written by binaryLV

@binaryLV You are correct on that. On 32bit systems, php/apache can not handle files over 2GB

Written by Colum

Accepted Answer

  1. post_max_size should be 3G

  2. upload_max_filesize should be 3G

  3. memory_limit depends!!! what you are going to do with the file. If you are going to manipulate the file or do other memory intensive jobs, then you will need to set a high limit. If you don't want to put a maximum limit, you can always set it to -1. This value doesn't have to do much with the size of the file, but rather with the size of the physical memory your script needs to handle the job.

For the first two, it is the maximum file size you expect to be uploaded, suffixed with a short hand byte value. For KB should be K, MB should be M, GB should be G, ...

Written by Shef
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the community.
It is licensed under cc-wiki