phplamppmax-size

"Maximum upload size" does not correspond to php.ini settings


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?


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?