maximum size of uploads in php depend on number of settings. here they are, as put into apache virtual hosts file:

php_admin_flag file_uploads on

php_admin_value memory_limit 560M
php_admin_value post_max_size 530M
php_admin_value upload_max_filesize 500M

php_admin_value max_execution_time 0
php_admin_value max_input_time 0

please ignore the values above, but they enable me to allow uploads of around 150-200M. memory_limit, post_max_size and upload_max_filesize have some specific ratios between each other. i believe that

upload_max_filesize < post_max_size < memory_limit

however, i dont' know how to calculate exact sizes. for example what must be values of these settings in order to allow exactly 100M file upload? from what i gathered online, there is number of factors that determine these ratios, but i couldn't find any references what are these factors.

i'm using linux system.


The memory limit is independent of the POST size you upload files. The uploaded files will be parsed directly by PHP and put in a temp folder.

The upload_max_filesize must be 100M and your post_max_size must be 100M + the overhead of the multipart encoding. The overhead is low as it is binary encoded with a boundary. Even with 101MB it will work.

Now, it may still crash your script if you then do $file = file_get_contents('path/to/uploaded/file.ext'); because in this case the memory_limit will kick in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.