Fixing Media File Upload Errors in WordPress

Today I’m troubleshooting an issue on a site that I just migrated across from another server. The site is fine but when my client tries to upload anything to the Media manager, she gets this error:

Unable to create directory uploads/2022/05. Is its parent directory writable by the server?

Here’s the checklist I ran through in order to resolve this issue for her.

1Check the sizes of the files that are being uploaded.In this case the files are 195 KB (a jpeg) and 685 KB (a PDF) respectively.
2Attempt to upload these same files to recreate the issueOn doing this the error is as shown above. The max file size is current 512 MB so no issues with a limit set on the file sizes.
3Check the media folder settingsGo to Settings > Media and check the setting for the Uploads directory. Check it matches the location of the Uploads folder on your server (the default is/wp-content/uploads).

NOTE: Sometimes the media folder settings field isn’t visible in the Dashboard, in which case you need to use a code snippet to add a short section of code to the functions.php file defining the uploads directory location.

Lucky for me in this case it was all sorted by Step 3: the upload directory referred to a folder structure from the old server that did not exist in the new one. However, I did have a moment of panic when, after changing this, the uploads were still failing with the same error. If this happens… clear your cache! I have LiteSpeed cache running on this site so did a full clear and then tried the upload again: all good (phew.)

Additional steps to check after this (if Step 3 hadn’t resolved my issue) would have been to check the Uploads folder had read/write permissions.

4Check the folder permissionsYou do this via FTP or directly on the server. In cPanel, click on the File Manager and select the folder then click Permissions.
Change the settings to that User, Global, and World are all set to have full permissions (Read, Write, and Execute with the code 777).
Test this by attempting the uploads again.
Revoke the permissions by resetting so that only the User has full permissions (Read, Write, and Execute with the code 755.)

NOTE: You must reset the permissions to revoke full access for the Global and World settings or you are leaving your site wide open to attack.

More Like This

Do you need someone to maintain your WordPress site?

Whether you’re looking for a monthly maintenance plan or occassional updates, we can help.