Looking for new opportunities
I am always looking for a new opportunities to expand my knowledge and help others while doing so, there for if you are looking for someone to join your team or you have something you want some help with feel free to reach out via email.
Yesterday Jeff Madsen has sent a small Laravel tip which address how you can validate
the post size for your uploaded data via Laravel middleware called
Even though the solution is valid when you have no control over your server, but when you do, you should fix the base of the problem which is your web server (in my case its Nginx ).
Normal when you upload a file, the process looks like this :
And the data get back from 3 to 1 .
Now as I said the solution which was provided solve the problem at the PHP processes level not at the Web server, at the end the data need to go through the server first.
In nginx documentation we have a core module which control the size of the data which the client can send through the server, the default size is 1Mb, so to fix this problem you need to do the following:
/etc/nginx/nginx.confand make sure that the value for
client_max_body_sizeis big enough like:
php.inifile to make sure that you have setup the upload size and memory with big values like :
memory_limit = 128M post_max_size = 100M upload_max_filesize = 200M
lastly you need to restart nginx.
now just a small note, you will need to adjust the values based on your needs, there are no magic values which can solve your issue here.
If you find that this information is incorrect, please let me know via email z[At]zah.me. I'll be happy to get more information about this topics from experienced people out there.
PS: as usual, since english is not my mother language, you might find some errors, so if you do let me know and I will be happy to fix it.