tags:

views:

55

answers:

4

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 max_filesize?

A: 

Yes; memory_limit needs to be bigger than upload_max_filesize.

You'll also need to increase post_max_size ... as files are uploaded via a POST request.

GingerDog
Objection! `memory_limit` does not need to be to bigger than `post_max_size` if the only reason of raising it is file uploads, as the uploaded files are stored in `/tmp` not in memory.
Notinlist
The first phrase is wrong.
Artefacto
A: 

I typically use upload_max_filesize<post_max_size<memory_limit as a rule of thumb, when configuring PHP.

naivists
Any thoughts on what I should set these values for when I'm expecting uploads of videos of about 200MB or so?
tzmatt7447
post_max_size = 210 MB; upload_max_filesize = 200 MB; memory_limit = 32 MB (or something)
Notinlist
+2  A: 

post_max_size must be bigger than upload_max_filesize. If a form contains more file uploads then the post_max_size must be greater than the sum of them.

The memory_limit does not have any significant role in file uploads, as uploaded files are stored in the /tmp (Linux) directory, not in memory. If you want to submit large amount of data with form fields (not file uploads) then you need a big memory_limit otherwise not.

Notinlist
+5  A: 

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.

Artefacto
The source-code link is nice :-D
Notinlist
@Notinlist He probably not the most beautiful example -- a 600 line function...
Artefacto
Thanks Artefacto - I think the upvotes indicate that your argument is correct...
tzmatt7447