You get a bonus - 1 coin for daily activity. Now you have 1 coin

PHP: can't upload a file larger than 8 MB (even with a higher max_upload_filesize)

Practice



So, you can't upload a file larger than 8MB to your site on the server (typically 8MB). You know about the max_upload_filesize option and, of course, you set it to a larger value (for example, 32MB), but that didn't help — you were only able to upload files larger than 2MB, but for some reason you still hit an incomprehensible barrier around 8MB, and that's it.

The thing is, PHP doesn't limit input data only via max_upload_filesize. The file is transferred via a POST request, and PHP doesn't allow the POST request to be too large (for understandable reasons).

The maximum length of a POST request is controlled by the max_post_size parameter. Playing around with it and setting it to a large value, you'll most likely find that large files start uploading successfully and reach the PHP handler.

PS. Just in case — these options are specified in the php.ini file. Where this file is located depends on the OS the web server is installed on; you can look up the file location depending on the OS in the article (

Where the PHP settings file - php.conf (php.ini) - is located in Linux Debian, CentOS/RedHat and FreeBSD

)(for Unix systems). On Windows it's located together with PHP

Applies to: PHP 5.x

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Running server side scripts using PHP as an example (LAMP)"

Terms: Running server side scripts using PHP as an example (LAMP)