I recently moved a WordPress site from one location on a server to another location on the same server for a client. Everything seemed to work fine after following the directions in this article I had previously published. That article was specifically published for changing the domain that points to the WordPress site which could include simply changing the domain only or actually moving the site to a new server or new location on the same server and a new domain. If you are performing the second of those two options you may also need to update the “upload_path” depending on the configuration of the new server and if the paths are the same as they were on the initial server the WordPress site was installed on.
Possible Errors When Uploading Files To The WordPress Media Library:
In the example case mentioned at the beginning of this article my client was not receiving an error. When they attempted to upload files to the WP Media Library it seemed to work without issue but when they attempted to view the file it didn’t display and appeared to have not uploaded. After a bit of troubleshooting I realized that the path existed that they were attempting to upload to but it was not the correct path on the server. So the client was not receiving an error because the file was uploaded without issue but when attempting to display the file it was looking in the new location on the server.
How To Resolve WordPress Media Library Upload Issues:
The first place to look in the event that there is an issue uploading media files to a WordPress site after moving the WordPress site between servers, moving locations on the same server, or modifying the WordPress domain or URL would be the upload_path variable located in the wp_options table. Below is the example displayed from the WordPress site the client had an issue uploading media files too.
WordPress upload_path Variable In MySQL wp_options Table:
- mysql> select * from wp_options WHERE option_name = 'upload_path';
- +-----------+---------+-------------+-------------------------------------+----------+
- | option_id | blog_id | option_name | option_value | autoload |
- +-----------+---------+-------------+-------------------------------------+----------+
- | 59 | 0 | upload_path | /var/www/wpsite/wp-content/uploads | yes |
- +-----------+---------+-------------+-------------------------------------+----------+
- 1 row in set (0.00 sec)
The problem with the above upload_path value of “/var/www/wpsite/wp-content/uploads” is that the new site was located at “/var/www/newsite” and so the upload_path value should be “/var/www/newsite/wp-content/uploads”. Below is the SQL syntax that can be used to change the upload_path value to the proper path.
Modify The upload_path Value To The Proper WordPress Uploads Directory Path:
- mysql> UPDATE wp_options SET option_value = '/var/www/newsite/wp-content/uploads' WHERE option_name = 'upload_path';
- Query OK, 1 row affected (0.00 sec)
- Rows matched: 1 Changed: 1 Warnings: 0
After making the above modification to the option_name titled upload_path to reflect a updated option_value of the new WordPress site uploads directory you can verify the change by viewing the row from the MySQL CLI as displayed below.
View Updated upload_path For Path To WordPress uploads Directory:
- mysql> select * from wp_options WHERE option_name = 'upload_path';
- +-----------+---------+-------------+----------------------------------------+----------+
- | option_id | blog_id | option_name | option_value | autoload |
- +-----------+---------+-------------+----------------------------------------+----------+
- | 59 | 0 | upload_path | /var/www/newsite/wp-content/uploads | yes |
- +-----------+---------+-------------+----------------------------------------+----------+
- 1 row in set (0.00 sec)
- mysql>
You should now be able to upload media files to the WordPress Media Library without issue.
I had the same problem. Checked my settings in the database but could not find any wrong settings.
There was only one difference: other than described in this blog I do not know the absolute path to my document root and thus not to the upload folder (it is hidden from me and I’m jailed to a chrooted “/”). Although I thought it would not make any sense I then changed the upload path from /wp-content/upload to wp-content/upload (notice the missing leading slash). Then file upload to the media library worked again – but I guess it’s not granted, that under some circumstances the relative path may lead to some other problems.
Hello Kai,
Cool. Thanks for adding as others may run into similar issues and find the information you added useful. Thanks for taking the time to leave feedback.
Thanks.
alex