How to Upload and Manage Huge Files in WordPress
Many business websites have important documentation for visitors to download. These might be annual reports for corporations, financial reports for non-profit groups, application and intake forms for hospitals, or print documents for trade printers and photographers.
Whatever the type of file (PDF, zip, tiff…) it’s almost guaranteed to have a large file size. And this is a problem when you’re trying to upload it to your WordPress Media Library.
Many users see an error when trying to upload larger images in WordPress. This is due to the file size limit. In this article, I’ll show you how to upload and manage large files to use in WordPress.
Most website hosting companies try to manage the storage space on their servers by imposing a maximum file size limit on your WordPress application.
If the limit is lower than the file you are trying to upload, then you will see an error like this: ‘ filename.jpg exceeds the maximum upload size for this site’.
This isn’t a bad thing – large files take a long time to upload, process and download in browsers, making your website painfully slow.
Another issue which may stop you from uploading large files is memory limit.
By default, your WordPress site is allowed to use a reasonable amount of memory. When a script runs for too long and exhausts the defined memory limit, then you will see an error.
If you’re encountering either of these errors, here are two solutions so you can easily upload large files to WordPress.
The First Solution (if you’re into coding)
If you want to upload large image and media files in WordPress, then here is how you will fix image upload size issue in WordPress.
Simply add this code in your theme’s functions.php file.
@ini_set( 'upload_max_size' , '64M' ); @ini_set( 'post_max_size', '64M'); @ini_set( 'max_execution_time', '300' );
This code tries to increase upload maximum filesize, post maximum size, and maximum execution time limits for your WordPress site. However, this may not work for some WordPress websites.
In that case, you can try adding this code to your .htaccess file in your site’s root folder.
php_value upload_max_filesize 64M php_value post_max_size 64M php_value max_execution_time 300 php_value max_input_time 300
If both of these methods fail, then you can try adjusting these values using php.ini file.
The php.ini file is a configuration file used by PHP to define settings. Users on shared hosting, typically don’t have access to the main file. However, you can still create an empty php.ini in your site’s root folder using an FTP client.
Simply add this code in your php.ini file:
upload_max_filesize = 64M post_max_size = 64M max_execution_time = 300
The Plugin Solution (no-code, FTP managed files)
In some cases, you might not want, or probably shouldn’t have your large files sitting in the WordPress Media Library, which is typically open to search engines and public access. You might already have your files uploaded to a different folder path on the same server and need only to link to them from within your WordPress admin.
Either way, you can skirt around the maximum upload file size by sending your large files directly to your server using a File transfer Protocol (FTP) client such as Filezilla or WS_FTP Pro. File Transfer Protocol (FTP) is a fast and simple way to transfer files from one computer to another over the internet.
So, let’s imagine you’ve got eight PDF files averaging 6MB each. They are sensitive documents that need to be linked to on the website. Your hosting company has an upload limit of 2MB per file.
Now, when you upload a file to WordPress’s Media Library, it’s stored in a specific folder and goes through a little bit of processing (resizing, cropping, and tagging). An uploaded file is also added to the WordPress database so that the system knows the file exists and how it can be used.
But if you upload a file to the server, WordPress won’t recognise it without a little help. Here’s where I recommend installing a very helpful plugin called “Add From Server”.
“Add From Server” is a quick plugin which allows you to import media & files into the WordPress uploads manager from files on the web server.
Once you’ve connected to the server with your FTP client and uploaded the files to your folder of choice, you can search for and import them into the WordPress Media Library, independent of file size limitations.
Once you’ve searched for your folder and imported the large files, they will be available in your Media Library for linking or placing in your WordPress pages and posts.