[Solved] WordPress Upload Error: Unable to create directory uploads/XXXX/XX
A client from one of my Managed VPS reported a weird error today. They were getting following error when trying to uploaded media using WordPress Media Uploader,
“bc0073bd9db6888b13d46a3d6dc513ee.png” has failed to upload.
Unable to create directory uploads/2020/01. Is its parent directory writable by the server?
Here's an screenshot of the error they received,
The error was "weird" because it didn't make any sense. I checked file permissions and they were properly set. But still WordPress can't seems to create a new directory inside uploads and hints towards incorrect file and folder permissions.
So if you see this error, first thing you need to check is file permission. Your uploads directory should have 755 permission set and files & folders should be owned by webserver.
I fixed the error by defining uploads directory on wp-config.php. If you're in the similar situation open your site's wp-config.php file and look for this line,
/* That's all, stop editing! Happy blogging. */
Add following line just before it in a new line.
define( 'UPLOADS', 'wp-content/uploads' );
This fixed the issue for me. Client was able to upload files as normal after that. I have no clue why this happened. The site was recently migrated to my Managed VPS from GoDaddy. So may be something happened during the migration.