When it comes to uploading large files (videos in particular,) you will be screaming at your computer wondering why your files won’t upload! This is due to a few things, one in particular is not at all obvious (and took me hours to figure out.) The PHP configuration file (php.ini) has default upload limit settings, which should suffice for most web applications, but for videos and other large files, they are way too small. First, let’s increase those limits. Find and open your php.ini file and enter/edit these values with the following:
upload_max_filesize = 2G post_max_size = 4G max_execution_time = 0
The first setting is the obvious one, increase the max upload filesize to 2GB (you can always increase this if needed, of course.) Secondly is your post max size, which is the maximum for the total amount of data per single post. Think of it as uploading multiple videos all at once – the maximum combined size. Always make this number bigger than your upload max filesize, I have doubled it here – which is a bit overkill – just in case. Next up is the max execution time, meaning how long the php script will run before it times out. Just in case your internet is running slow and it takes a bit longer than usual – I set it to zero which means unlimited.
Those are the easy things, but your files still may not be uploading! If you are running FastCGI you may get a mod_fcgid error, which can be fixed by editing your virtual hosts:
If my math is right (doubt it,) that should be about 2GB. Now, if you are poor like me and can’t edit your virtual hosts file because you are on a shared server, you will have to switch to standard CGI. Sucks but, it is what it is, unless someone can comment on this post and help me out on that so I can go back to FastCGI!
Lastly is the super tricky thing that took me hours to figure out. I was able to upload files up to ~220MB but no more, why!? I didn’t even get any errors in the log file, no debug information, it simply stopped uploading and failed. The reason, I found out, was because of the default directory PHP uploads to wasn’t big enough! Create yourself a new “tmp” directory in the root of your server and open back up php.ini and enter/edit this line:
upload_tmp_dir = /home/your_shell_username/tmp
Just like that, it works!!!