PHP/Laravel: Input::all() and Input::file(‘files’) coming back as empty arrays when uploading large files (videos/images)

Are you trying to implement an image or video uploader in your PHP project, specifically a Laravel 4+ project, and you find that the upload HTTP POST is indeed hitting your controller method but Input::all(), Input::file(‘files’), and $_FILES are all empty arrays? Well there is a really good chance its not your front-end nor your back-end code that is the problem, its most likely its PHP playing a cruel trick on you. According to the PHP documentation, if the php.ini default settings are in play, PHP is restricting file uploads that are bigger than the default size of 8 megabytes.

Yes that is correct, in today’s modern world of web development and today’s internet of media, the makers of PHP have decided that file uploads should still be restricted to a file size more appropriate for the late 1990’s. But on top of that, instead of providing a warning message in the HTTP Request object that the limit is being exceeded, PHP just simply removes the request objects all together and pretends nothing was submitted with the request at all, leaving the developer in a complete state of profound confusion.

That being said, go change your defaults (CentOS specific):

nano /etc/php.ini

Search for each of these default keys and set the values you feel best fit your needs:

memory_limit = 4000M
upload_max_filesize = 1000M
post_max_size = 1500M

Restart the Apache service:

service httpd restart

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s