I’ve been working on a Laravel project which uses relatively large file uploads (about 30MB - 120MB). My development environment is Laravel Homestead - a great, pre-packaged Vagrant box for Laravel development. If you haven’t heard of this I highly recommend you check it out - it’s a great way to get up and running with Laravel, but it doesn’t seem to play well for larger file uploads through forms (over about 5MB). My forms were either hanging or returning an nginx ‘too large’ error. Here are some of the settings which I’ve had to tweak to get Homestead working nicely with larger uploads.
Make a backup of your Homestead settings and files before making any tweaks so that if anything goes wrong you can revert to a working copy. First, increase the limits in your php.ini. This can be found in
/etc/php5/fpm/php.ini. Here are the settings I’ve overridden (note: these are spread throughout the php.ini file - I’ve just put them all together for convenience):
max_execution_time = 500 upload_max_filesize = 128M post_max_size = 128M
The main two settings here are the
post_max_size, but I’ve also increased the
max_execution_time to allow for the longer time to process the file and upload. You can set all these accordingly.
Once you’ve updated your php.ini you’ll need to reload it by running the following command in your terminal:
service php5-fpm restart
The next set of changes are in the nginx.conf file, which you can find at
Within the http section, set sendfile to off:
Just below this line, add another line to specify the
Once you’ve done this, save the file and run the following command in terminal to reload the config:
nginx -s reload
That should be it - you can now use your Laravel Homestead environment to upload much larger files. I hope this helps. If anyone has any tips related to this issue, please feel free to share them in the comments below :)