Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In PHP settings, should memory_limit > upload_max_filesize?

Tags:

php

I'm trying to allow users to upload large files (64MB) and am planning to change upload_max_filesize to 64MB.

However, should I also change memory_limit to 64MB or larger?

Is memory_limit connected to upload_max_filesize?

like image 313
tzmatt7447 Avatar asked Sep 06 '10 11:09

tzmatt7447


People also ask

What should PHP memory limit be?

A typical appropriate memory limit for PHP running Drupal is 128MB per process; for sites with a lot of contributed modules or with high-memory pages, 256MB or even 512MB may be more appropriate.

What is upload_max_filesize PHP?

In order to preserve your server's resources, hosts set a limit on the maximum size of a file that can be uploaded. This maximum, in megabytes, is defined in the upload_max_filesize directive. The upload_max_filesize directive itself is located in the php.

How do you fix the setting for Post_max_size is smaller than upload_max_filesize?

Navigate to your php.Locate the upload_max_filesize and increase it by changing its number. You can also boost a few other limitations, as shown below: upload_max_filesize = 256M post_max_size = 256M memory_limit = 512M max_execution_time = 180. Save the file, and that's it. The error should no longer occur.


1 Answers

No, it's not necessary.

PHP has different POST readers and handlers depending on the content type of the request. In case of "multipart/form-data" (what is used for sending files), rfc1867_post_handler acts as a mixed reader/handler. It populates both $_POST and $_FILES. What goes into $_POST counts towards the memory limit, what goes into $_FILES also counts.

However, $_FILES has just meta-data about the files, not the files themselves. Those are just written into the disk and hence don't count towards the memory limit.

like image 130
Artefacto Avatar answered Sep 28 '22 20:09

Artefacto