media upload "the uploaded file could not be moved"
-
This problem occurs when attempting to upload media items through the dashboard. The error text shown (using the flash uploader) is something like “upload error: the uploaded file could not be moved to wp-content/uploads”.
I thought I would post my solution to this, since a quick search through the forum contained many suggestions such as “change permissions to 777”, “delete the wp-content folder and re-create it”, etc., none of which solved the problem for me.
I’m running wordpress on fedora 16 (linux) which has SELinux enabled by default (as do many/most current linux distributions).If you’re running on a linux system with SELinux enabled, this solution may apply to you. One way to confirm whether this solution will work is to quickly check (tail) the /var/log/audit/audit.log file for new “denied” entries being created as you try to upload media files. This may also apply to uploaded themes, plugins, etc. This is a safer way to determine what’s going on (and why) than simply disabling SELinux altogether.
Solution:
1. Make sure that user ownership is properly configured on the directory where your wordpress installation is located. Assuming it’s being run by user and group ‘apache’, and that your wordpress installation lives at ‘/var/www/html/wordpress-home’ you can configure all at once with something like:
chown -R apache:apache /var/www/html/wordpress-home
2. Make sure the proper (SELinux) label has been applied to the wp-content folder (and children) ; the following command should work:
chcon -R -t httpd_sys_content_rw_t /var/www/html/wordpress-home/wp-content
Note that you can view the SELinux context applied to files in a directory using the ‘-Z’ option to the ls command.Step #2 was the critical point for me–even though permissions were changed to 777 (r-w-x for anybody), wordpress still could not write files to the uploads folder if it had the wrong label applied to it.
3. Make step #2 permanant; if after executing step#2 the uploads work for you, you’ll want to apply this change in a more permanant manner with the following commands:
semanage fcontext -a -t httpd_sys_content_rw_t "/var/www/html/wordpress-home/wp-content(/.*)?"
(this adds a rule to apply the specified context change permanantly)
restorecon -R -v /var/www/html/wordpress-home/wp-content/
(this restores the context of the wordpress wp-content folder according to the configured rules)Note that the SELinux policy is also probably the reason why you can’t get the wp-admin/install.php script to generate a wp-config.php file automatically for you (not that it’s terribly hard to copy-paste the output into the file manually anyway).
- The topic ‘media upload "the uploaded file could not be moved"’ is closed to new replies.