Table of Contents Hide
Last Updated on December 11, 2021 by Rovamedia
Uploading files and content over your WordPress CMS is meant to be stress-free and fun. But in most cases you will be confronted with some critical problems, then you will be imagining yourself handling the problems in different scenarios.
If you are an avid user of the popular WordPress Content Management System (CMS), you will attest to the underlying issue that occurs when you are trying to publish pictures or other files to your site. The error states ‘Upload: Failed to write file to disk’. Now, this error doesn’t give much idea to the user as to why it appears and the solution to this problem and can be frustrating for amateur beginners.
What Causes The Error?
This error can occur due to several reasons. We categorize all those reasons under three common parameters and by the end of this article hopefully, you would be able to fix this error like a pro.
- Permissions setting to the upload directory. In this case the upload directory or folder to which the elements are supposed to the stored in has a persimission that makes it not possible to accept a file upload to it. In most cases, the directory may have been set to a read-only attribute by your hosting provider or you.
- The user exceeds the granted quota or hard drive of the server has no space left. In this case, the hosting server hard disk drive has 0 spaces of bytes left to contain any data to be uploaded into the drive. This can posed the error, because if the disk space quota is low or has been exceeded, there can be no transmission of elements.
- The tmp folder of the server has no space left. Web servers have a directory named /tmp used to store temporary files. Many programs use this /tmp directory for writing temporary data and generally remove the data when it is no longer needed. Otherwise the /tmp directory is cleared when the server restarts. So if this folder has no space left as attributed to it by the server, you will meet the error.
How to Fix Upload: “Failed to Write To Disk”
To fix this error, you need to check your website or server hosting space to begin.
Warning! Before you implement any of the steps below, ensure you have a very recent backup of your site. Read our guide to learn How to Create WordPress Backups.
1. Check Your Upload Folder Permission
Normally, this folder should have 755 permission, and if this is not the case, then change it to 755 right now. By default, WordPress uses the 755 permissions algorithm system to facilitate the transfer of files on your website via the hosting server.
To achieve the 755 permission kindly right-click on the wp-content folder and select file permissions. This is because WordPress needs access to write files in your wp-content/uploads directory to enable certain functions, and if this permission is not set correctly, then you will not be able to upload media to your WordPress site.
You also need to make sure that file permissions for individual files in your wp-content folder are correct. Once again, right-click on the wp-content folder and select file permissions on each folder. This time change permissions for files. Lastly, you need to click on ‘Apply’ or ‘Change Permissions’ whichever are denoted by your hosting provider. At this point, you can retry the process of uploading to your WordPress site.
2. Check If The Storage Quota Has Been Exceeded
Most times users don’t know the full difference between ‘private hosting’ and a ‘shared hosting’. Users on web hosting services with shared hosting plans get packages with very low storage space, such as 500MB, 1GB, 2GB, and even 3GB.
If you are hosting multiple WordPress sites and upload lots of pictures on this kind of web hosting packages, then chances are that even 1GB or 3GB storage will soon become filled. If the storage quota is exceeding, then your web host won’t allow you to upload any other files, and this error occurs.
If you experience this issue, at this stage ask your hosting company to upgrade your web hosting plan to a more advanced one to enable you to upload content and make use of a broader webspace.
To check your allocated space, Login to your cPanel and check the left sidebar. Notice the “Disk space usage” field, which will inform you how much disk space you are using, and your total space as per your hosting plan.
3. Check If .htacess File Has Been Modified
.htaccess is a configuration file for use on web servers running the Apache Web Server software. When a .htaccess file is placed in a directory that is in turn ‘loaded via the Apache Web Server’, then the .htaccess file is detected and executed by the Apache Web Server software. These .htaccess files can be used to alter the configuration of the Apache Web Server software to enable/disable additional functionality and features that the Apache Web Server software has to offer. These facilities include basic redirect functionality, for instance, if a 404 file is not found error occurs, or for more advanced functions such as content password protection or image hotlink prevention.
The .htacesss contains certain functions (basically PHP strings of code), that make the transfer of files and other elements very easy and possible servers. In most cases, the limit of file upload might be restricted using the .htaccess by default either from the theme, hosting provider, or even the WordPress setup.
To fix this, go to the web hosting folder containing your website files. Make sure you checkbox the ‘show hidden file’ option in the cPanel. The quickest fix for the uploaded file exceeds the upload_max_filesize directive in php.ini. error is increasing your PHP resource limits using the .htaccess file.
Increasing the upload_max_filesize value should do the trick. Add this line at the bottom of your .htaccess file to do it:
- php_value upload_max_filesize 256M
Once done, try to perform the same action in WordPress which caused the error to appear and it should be gone. If it still persists, you may try increasing additional PHP limits, such as:
- php_value post_max_size 256M
- php_value memory_limit 512M
- php_value max_input_time 180
- php_value max_execution_time 180
Don’t forget to save your changes. If everything was done correctly, the WordPress error should no longer bother you.
You can set the PHP limits to any desired values as long as your server supports it. The maximum available limits can be located by creating a PHP info file.
How Can You Use This Information?
Uploading media and other generic content is absolutely important to a good online presence. Hopefully, you have been able to fix the upload error issue and move forward strongly on your web presence.
Next, it is very necessary to avoid getting into this situation in the future and you can do this by assigning the default permissions for your webspace. If you have any other steps you used in getting out of the “file upload error” warning, please share them in the comments below. For more WordPress tutorials and guides follow our WordPress blog.