Image upload errors in WordPress are pretty common and are typically experienced in the very beginning of one’s blogging or webmaster career. The reasons for that are two: beginners tend to use shared hosing that often has a setup causing troubles; beginners are also more likely to overuse plugins or try to tweak settings that sometimes can break things down.
This post will help you understand the cause behind the most common image upload issues in WordPress and will guide you step-by-step through the solution to each of them.
HTTP Error on Image Upload
HTTP error on image upload can be observed both on new WordPress installations and on sites that have been around for a while. The symptoms are rather vague and can therefore leave one wondering, what is wrong, especially because the error notice (if you at all get one) can differ from browser to browser.
A HTTP error on image upload is characterized by the following:
- You cannot upload any images to the media library, regardless of size or format.
- You don’t get any explanation, just a short HTTP error message.
- You haven’t done anything, such as plugin installation or tweaking WordPress core files, that could cause sudden change of behavior of your site.
Please note that not all errors, occurring during image upload to WordPress are HTTP errors or can be solved, using the solution below. If you don’t think that your situation fits the description above, please scroll down to the sections of this post, discussing other common upload issues and their solutions.
The HTTP Image Upload Error Explained
This error is in most cases experienced by people, using shared hosting and occurs due to limitations, enforced on individual hosts to prevent CPU abuse.
Let’s take a detailed look at the issue: whenever you upload an image to the media library in WordPress, it is processed on the server by Imagick, an image processing tool. Imagick tries by default to use a multi-thread connection in order to process the image as quickly as possible.
Shared web hosts, however, tend to block users from running multi-thread tasks, as this could result in CPU abuse. This creates a conflict with Imagick and results in HTTP error on image upload.
This is, with other words, not a WordPress but a server issue and should be solved on the server.
Solving the HTTP Error
Shared hosts have, unfortunately, strict rules, regarding server configuration. This means that you won’t have any success trying to convince your hosting company that it is necessary for you to get permission to use multi-thread.
Instead, you can instruct Imagick to use a single thread to comply with the server requirements. You can do this by following these simple steps:
- Log onto your server (or access it via FTP)
- Open File Manager
- Navigate to the public_html direcotory and click on it (if your site is installed on a subdomain or in a subdirectory, locate and open the respective directory, usually found in public_html)
- Find .htaccess and open the file. You can, alternatively, download it and edit it locally, if you prefer..htacces is found in the same directory as your wp-content, wp-includes, and wp-admin directories. It is a hidden file, so you must check the setting Show hidden files in order to see it.
- Add the following line at the top of the file: SetEnv MAGICK_THREAD_LIMIT_1
- Save the file without changing its name and, if you edited it locally, upload it back to the server.
This instructs Imagick to use a single thread only and should solve the HTTP error. As long as it didn’t and you are sure that there isn’t any other possible cause to it, please contact your hosting provider for advice. First though, you might want to check, whether there isn’t an alternative solution to your image upload issue.
Common Image Upload Issues in WordPress
Besides the HTTP error, WordPress users deal often with the following types of image upload issues:
- PHP memory limit
- PHP upload limit
- Missing permissions
- Plugin-related issues
Let’s discuss them one-by-one.
PHP Memory Limit
PHP memory limit is a limitation, set on the server, affecting the amount of memory (RAM) a script can use. Very often, shared hosting providers set the PHP memory limit very low, at for example 48MB. However, in order to function properly, WordPress needs at the very least 64MB and various themes and plugins can require even more.
If you are facing PHP memory limit issue on image upload, you’ll get a message as “Allowed memory size of xxxx bytes exhausted“. Such error affects often not only image upload but also simple tasks as publishing a new post.
As there already is a post on dealing with PHP memory limit on WPBloggingNerd, you can learn more about this type of error and get comprehensive guidance regarding its solution, by following the link in this sentence. The proposed solution will solve any image upload issues as a result of PHP memory limit.
PHP Upload Limit
PHP upload limit is in its essence the same as PHP memory limit with the only difference that it is the size of uploaded files that is limited. This limitation applies to any upload via the WordPress admin panel, including but only image upload.
Usually, even on shared hosting, the file size limit for uploads is pretty high, such as 125MB. Occasionally, it can happen that the limit is set low or an upload, such as a premium theme, plugin or very large image, can exceed it.
You can check the current limit set for your site by clicking on Media->Add new in WordPress admin panel. Under the Browse field you can see the current upload limit.
As long as you need to change the limit, you can do it by following these steps:
- Find php.ini on the server. It is located in the same directory as your wp-content, wp-includes, and wp-admin directories, usually public_html.
- Back the file up locally
- Open it and find a line with the exact expression upload_max_filesize, ending with the current value. Change the value (be careful to not remove or change anything else and remember to format the new value precisely the same way as the old one). If the old expression reads: upload_max_filesize = 60M, you should change it as follows (with a value of your choice but please be reasonable, especially on shared hosting): upload_max_filesize = 250M
- Save the file
Keep in mind that not all web hosting companies allow you to modify the PHP settings. Thus, it might happen that nothing changes, even though you did everything right. If that’s the case, you can ask your hosting company to change the settings for you. Often though, you’ll get to know that it is against their policy to change them. Unfortunately, this leaves you without any chance to solve the issue. The only thing you can do is change hosting company.
You can, however, use a workaround. No matter the upload limit, you can upload anything, including images, to your site via FTP. You should locate the uploads directory in the wp-content directory (public_html->wp-content->uploads->year->month). In it, you should find the subdirectory you want to upload to. Subdirectories in this directory are usually following the years and months.
Using this method allows you to directly upload and link to images, using their URLs. It does, however, not add the images to the media library. If it is important to you to see them listed there, you can install the Add from server plugin, helping you locate and add images and other files from anywhere on the server to the media library.
Very rarely, image upload issues can be caused by missing permissions for the upload folder on the server. In such case, you get a notice that WordPress cannot write in the chosen directory.
The reasons behind this issue can be many: wrongly configured hosting account, hacker attack, or inadvertent reaction to other changes on the server.
No matter the reason, you can easily fix the issue:
- Access public_html->wp-content and locate the uploads directory via FTP
- Right-click on it to show a dialog box with options
- Click on File Permissions
- Set the file permissions as shown in the screenshot below. You can at first try to set the numeric value to the more secure 744 (it only gives Execute permissions to the Owner), however this is not a solution that works on all servers.
- Click on OK. That should solve the problem.
Every now and then image upload issues can be caused by plugin errors. It might either be due to plugin incompatibility, errors in the code, or incorrect plugin settings, especially of image optimization plugins.
Typical for such issues is that they appear after an event, such as installing a new plugin, updating plugins, themes or WordPress, or tweaking plugin settings.
As long as you are aware of any recent changes on your site, you should retrace your steps and undo such changes. Check whether the issue is resolved. If not, you might have to follow the troubleshooting procedure, described in the plugin incompatibility post.
Image upload issues in WordPress are, ironically, most of the time caused by issues or settings not related to WordPress itself. The two most common issues are the HTTP error and the PHP memory limit error.
While the solutions to such errors are simple, often it could turn out to be impossible to fix them due to the policy of hosting providers. Fixing the image upload issue can therefore often become a question of whether or not you should find new hosting provider.
Serving images and other media, such as HD video, is central to managing a website, which is why requiring that hosting providers enable you to do that is reasonable.