Question

I'm using lampp on ubuntu and I want to change the maximum upload size.

The php.ini in opt/lampp/etc has these settings:

post_max_size = 5M
upload_max_filesize = 8M

But when I try to upload a 2.1 mo file, I have this error message:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 7448 bytes)

Any idea please?

Was it helpful?

Solution

It's not because the post_max_size or upload_max_filesize, but because of memory limit
try this

ini_set("memory_limit","256M");

134217728 bytes = 128MB

or from php.ini

memory_limit = 256M  

But in general, when you got this error, it simply means that your code is not efficient yet. Because you are exhausting the allocated memory to run just this one PHP page. It's already 128 MB you know.
If you simply just increase the memory limit, the concurrent PHP processes that can be opened at the same time would be reduced significantly.
Try to think of massive multi-user environment, when this PHP page is opened by many users at the same time, can the server handle it all with the server's physical memory ?

Simply put, can you share your piece of code here so we all can help you to make it more efficient?

OTHER TIPS

Have you restarted Apache?

Have you tried the PHP method?

Have you tried the htaccess method?

PHP method

ini_set('upload_max_size', '64M');
ini_set('post_max_size', '64M');

Htaccess method

try putting this in your .htaccess file

php_value upload_max_filesize 64M
php_value post_max_size 64M

This error is not related to the max upload file size, it's related to the PHP interpreter trying to allocate more memory than allowed by the memory_limit flag.

Increase it's value in PHP.INI, reatart your server, check if the new value is in use with phpinfo() and see if your script works.

The error you are getting is not related to the file upload size. PHP is running out of memory (RAM) during the execution of your script.

You will need to increase your memory limit per the PHP ini settings: http://www.php.net/manual/en/ini.core.php#ini.memory-limit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top