How to increase the Maximum File Upload size in Drupal 7
While working with one of my Drupal 7 website project, I encountered a problem about the PHP "Maximum Upload File Size" limit set in the hosting provider. One feature that I need to implement to the site was to be able to upload a video file with the format (mp4, mov, flv, m4v, mpg, mpeg, ogg, ogv, mp3, oga). I am able to accomplish the video upload feature by creating a CCK file field that accepts uploading of video files limited to those file extension. I use the Mediafront module for Drupal 7 to play the uploaded file in the node.
The problem was the uploading of video files was limited to accept up to 8 MB and the limit was set in PHP.INI file, php.ini is a configuration file of PHP server installed in the host. Because the site is hosted in a shared server, I do not have an access to this configuration file and I can not adjust the settings easily. The website needs to upload at least up to 60 MB of video file size.
Looking for a solution and documentation on Drupal.org website on "How to increase the maximum file size upload" limit doesn't work in my situation. After searching for an hour for a solution and reading through all the recommendation Google search gave to me, I've found the one that works in my hosting provider, so here I decide to post and document it here in my blog. Please note that this may or may not work in some server because of various configuration setup but if nothing works for you, you can try this also and maybe we have on the same server hosting.
Here's what I've done
- First I've created an empty php.ini file and drop it where I've installed Drupal, im my case it is in the directory "home/user/public_html/dev" as I first develop the site in a sub domain and then migrate it to the main domain when it is ready. The exact location of my newly created blank php.ini after I drop it to my development site was "home/user/public_html/dev/php.ini" and I can access my dev site through this similar URL : http://dev.example.com.
- The second things I've done was to visit the URL of my dev site, and it gives me an error saying this "Fatal error: Class 'PDO' not found in /home/user/public_html/dev/includes/database/database.inc on line 185". Seeing this error means that the server is already reading the empty php.ini and because I put my own configuration file in this Drupal installation, this seems that its override or dis regard some settings in original php.ini and PHP does not load some additional extension that is set in there, for this example it is the PDO extension.
To be able for me to fix that PDO error I added this into my empty php.ini
After fixing the PDO problem I added the actual configuration code for the file upload which is :
post_max_size = 160M
upload_max_filesize = 80M
magic_quotes_gpc = off
This settings will increase my upload file size up to 80 Megabytes, that's cool!
- Here's the screenshot of the node editing forms