PHP upload size and its impact on post size and memory limit
Asked Answered
M

2

12

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.

Melosa answered 21/6, 2011 at 12:48 Comment(7)
Are you using 32bit or 64bit PHP?Plasticity
i am running 32 bit system (Fedora14)Melosa
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 aboutNonresident
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.Plasticity
@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 problemMelosa
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.Plasticity
@Plasticity You are correct on that. On 32bit systems, php/apache can not handle files over 2GBNonresident
S
8
  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, ...

Spanish answered 21/6, 2011 at 13:0 Comment(1)
what does memory_limit refer ?. Physical Memory or Secondary Memory ?Melosa
N
0

Your values should be the maximum size of the file you want to upload. So if you want 3GB, then each of those values should be 3072M (3GB in MB).

Nonresident answered 21/6, 2011 at 12:59 Comment(2)
Value 3072 would mean 3072 bytes. To specify 3072 MB, it should be 3072M.Plasticity
@binaryLV: You are correct, if the int value of the size doesn't have a suffixed byte value, it is assumed to be in bytes.Spanish

© 2022 - 2024 — McMap. All rights reserved.