PHP Upload File Size Not Correct


(Nic Hubbard) #1

I changed my php file upload settings in my php.ini (yes, both places) restarted apache, and now my phpinfo() shows that I can upload files up to 100M. But, when logging into Matrix, it still shows that my limit is 32MB. The global preference is set to 0, so it should use my php.ini settings.


Strangely, even though it shows 32M as the max, I CAN upload files up to 100M, which does follow my php.ini. So, my question is, what is going on here? Why is Matrix not displaying the php upload file size correctly, even though it is allowing my to upload files of that size?



Edit: Running 3.20.2


(Luke Wright) #2

The maximum upload size reported in the Matrix backend is the lowest of three settings in the PHP configuration: upload_max_filesize, post_max_size, and the PHP memory limit. Could you check your other settings, in particular the memory limit? If one of these values is only 32 MB, then the reported amount is working as intended.


As for why larger file uploads would still be working… PHP recommends that the memory limit be larger than the maximum post/upload size, because a small memory limit may stop PHP from processing a large POST request that would result from an upload. The PHP manual is otherwise silent on how exactly the memory limit affects large uploads, and so does not explicitly say that it will choke on, say, a 32 MB file if the memory limit is only 32 MB.



I would not be surprised if PHP 5 has improved the memory management of handing POST data, however the recommendation in the PHP manual remains, so it is probably best to continue to advise against uploads greater than the memory limit.



On the other hand, I don’t believe that Matrix will knock back file uploads that PHP and Apache itself allows (don’t quote me on this, have not checked the code thoroughly) - subject to it not running out of memory itself, or unless overridden using the File asset’s Preferences, by setting its “Max File Size” there to a lower amount.



Hope this helps a little.


(Nic Hubbard) #3

Luke,

Yes, you are correct, my php memory limit is 32MB, which is where this is coming from. I guess I was confused that this value was being used, and it might be confusing to users.

So far, uploading an 80MB file worked fine, but we will be sure to not make it habit.

Thanks.