Home » WordPress » The uploaded file could not be moved to

The uploaded file could not be moved to

A few hours ago I moved a site from HostGator’s shared hosting to their VPS server offering. While the process could have been much smoother, it had several bumps along the way. None more annoying than the following error when attempting to upload images or media on a post within WordPress:

The uploaded file could not be moved to /var/www/vhosts/yourdomainname.com/httpdocs/wp-content/uploads/2011/11.

In short, WordPress could not upload the image file. This is the last thing one would want to deal with when migrating a site. However, it is clearly a permissions issue and needs to be resolved on the server. Since most people are not server administrators, and neither am I, here are all the solutions I researched throughout the web in order from easiest to most difficult. Hopefully, one of these hacks will work for you.

Set the Default Folder for Uploads in WordPress

1) Login to WordPress and go to Settings > Media.

2) For the input labeled: Store uploads in this folder, specify the following as the value if it is blank:

wp-content/uploads

3) Save changes and test your ability to upload images. If you still have issues, move on to the next solution.

Changing Folder Permissions via FTP

On most VPS servers, you have to set permissions and ownership. Said differently, if you have the ability to set permissions but you are not the owner, then you will not be able to move or copy files into that folder.

WordPress tries to move uploads to the designated folder. However, if it does not have permission to do so, that would result in an error. It will only succeed if your write permissions are valid. Therefore, make sure your write permissions are correctly set and that you own the /uploads folder. Your FTP client displays the owner of the folder and is usually the username connected to the ftp server.

Below are instructions on how to change folder permissions via FTP:

1) FTP to your server, and navigate to the wp-content/uploads directory.

2) There, change the permissions of the /uploads directory to 777 (i.e., chmod to 777). In most FTP clients, you can right-click on the folder to get to the screen that allows you to change the folder permissions. If it asks you whether you would like to apply changes recursively, enable that as well.

3) Check WordPress by adding a new post and uploading an image. If it works, move on to the next step. If it doesn’t, then move on to the next solution.

4) If the previous step worked, now we’ll go back and change the permission of the /uploads folder to 755 (apply changes recursively). We’re doing this to avoid having a write-able (777) folder which is a security vulnerability.

NOTE: Do not leave your permission set at 777 – it exposes your site to hackers.

5) Check WordPress by adding a new post and uploading an image. If it works, then your issue is resolved. If it doesn’t, then move on to the next solution.

Changing Folder Permissions via Hosting Control Panel

Sometimes, the FTP user does not have the same privileges as the account owner. To ensure that changing folder permissions isn’t the solution, try logging into your host’s control panel and check the folder permissions from the File Manager. If they are correct, then move on to the next step. If is is not correct, edit the folder permission there and re-test the upload function through WordPress.

Creating a New Uploads Folder

1) FTP to your server, and navigate to the wp-content/uploads directory.

2) Rename the uploads directory to uploads-old.

3) Now, create a new folder named uploads. Change its permissions to 755.

4) Copy all sub-folders and files from the /uploads-old directory to the new /uploads directory.

5) Check WordPress by adding a new post and uploading an image. If it works, then your issue is resolved. If it doesn’t, then move on to the next solution.

Turn Off PHP Safe Mode

For some folks, turning off PHP Safe Mode may be the solution to this issue. However, not all users will be able to do this as many hosts restrict access or edit privileges to this file.

1) Navigate to your server

2) Locate the php.ini file. It is usually in your /etc directory from the root.

3) Open php.ini in a text editor and change the PHP Safe Mode value (if it exists):

On

to this:

Off

4) If the line does not exist, then add it.

5) Test your upload capabilities in WordPress.

Other Solutions

There are other potential solutions available however they are far more technical and require understanding of critical server files. Therefore, in the interest of preventing you from causing damage to your site and server, I won’t go into those here. At this point, if you are still having the issue, contact your host and have them resolve it.

Conclusion

I hope this was useful for folks having this image upload issue. Please let me know which solution worked for you in the comments below.

By

Charlie Patel is a world traveler, WordPress geek, serial entrepreneur, & consultant to big-shots in the corporate world and on the web. Otherwise, he's just planning the next trip or in some far-away land. He runs WPsite.net (this awesome site!).

Twitter Facebook Google+ Web Site

24 Responses to The uploaded file could not be moved to

  1. Mahamud Reply

    November 14, 2011 at 12:00 AM

    i face this problem like discuss by you but i don’t resolve it anyway. Please give some suggestion.

  2. WPcharlie Reply

    November 14, 2011 at 12:20 AM

    If none of these solutions worked, then you really should ask your hosting provider to ensure that uploads are allowed, and if they need to change permissions, they can do it from their end. Send them a support ticket.

  3. Can Berkol Reply

    April 13, 2012 at 9:01 AM

    If you get this error on a theme file that you want to upload or any other zip file; you can try to unzip and re-zip the file in your local pc and then upload the new zip file to your server. Sometimes especially zip files created in MacOs can cause issues in linux servers.

  4. Javier Rivero Reply

    August 7, 2012 at 10:43 AM

    Thank you very much, the solution “Changing Folder Permissions via Hosting Control Panel” worked for me, much love

    • WPsite.net Reply

      August 7, 2012 at 3:13 PM

      Glad you got something out of it Javier. All the best.

  5. Nishant Mittal Reply

    September 11, 2012 at 5:51 AM

    Thank you,the solution “changing folder permission via FTP”.
    and enjoy……….

    • WPsite.net Reply

      September 11, 2012 at 12:58 PM

      Glad you found it useful Nishant. Thanks for the comment. All the best.

  6. CMR Web Reply

    October 18, 2012 at 11:07 AM

    Just an FYI, I encountered this issue this morning. Here’s how I corrected it:

    I create test websites on my own server so my clients can see the website as it’s being developed. I have a re-seller hosting account. What the problem was is that I ran out of allotted disk space on my own website’s account because I had it set to one of my lower plans. Simply adjusting the amount of disk space for the account corrected the issue!

    I hope this helps anyone still having the above issue. :)

    • WPsite.net Reply

      October 21, 2012 at 5:23 PM

      Thanks for providing your solution. I’m sure it will be helpful to someone.

  7. Bobster Reply

    November 23, 2012 at 8:48 AM

    I hate to say but I am using LAMP on a home Linux mint maya system pc and I have 3 test web sites and only the first worked but then stopped after an upgrade of WP , I tried all the above on the latest version of WP and nothing worked so I guess Ill have to email my self and like most hosting sites wait for an answer lol

  8. Chaitanya Reply

    January 2, 2013 at 10:09 PM

    I am awaiting quick reply on this.
    Please help..
    This is what i did… Initially i set the permission of the wp-content folder to 777, to allow wordpress to create the “uploads” folder. I noticed in ftp client that the owner of the “uploads” folder was 99, other than the rest of the folders and its permission was 777. I was able to upload media through posts in that folder. Then I went back to change the permission of the”wp-content” folder, but it was already changed back to 755. Then i changed the permission of “uploads” folder to 755 via ftp, it gave error. Then i changed it from file manager in control panel. It changed…or I thot it got changed. But i when i reloaded it, it was back to 777. Whant do I do now?

  9. Daniel Reply

    April 3, 2013 at 9:45 AM

    I am following your advices:

    1) Login to WordPress and go to Settings > Media.
    OK DONE

    2) For the input labeled: Store uploads in this folder, specify the following as the value if it is blank:

    DO NOT SEE THIS OPTION. I only see Organize my uploads into month- and year-based folders which is ticked.

    • WPsite.net Reply

      April 3, 2013 at 11:54 PM

      @Daniel – The latest version of WP no longer has that input. It’s simply a checkbox of either organize into folders or not.

  10. Karishma Reply

    April 6, 2013 at 1:44 AM

    “changing folder permission via FTP” really worked for me.

    Thanks a lot!!

    You rock!!

  11. Jason Reply

    September 10, 2013 at 8:20 AM

    Hi,

    I changed my permissions to 767 and I can now upload. It is not ideal and a temporary fix in my eyes. Has anybody figured out why WordPress suddenly doesn’t work with 755 permissions?

    • WPsite.net Reply

      September 10, 2013 at 8:40 AM

      It’s not the best solution, but glad it worked for you. There’s no reason 755 should not work, but this could be more of a server-specific config matter rather than a prevalent issue.

  12. Jason Reply

    September 10, 2013 at 9:06 AM

    I figured it out for my site. If you have to change your permissions to 777, then (most likely) the www-data user isn’t a user of your var/www/ folders. To make www-data the user and group type the following command in Putty or whatever you use:

    sudo chown -R www-data:www-data /var/www

    chown is for change owners. -R is to make the change recursive (i.e. for subdirectories). the first www-data:www-data is the group and user and /var/www is the folders to which you are applying the user.

    To change the permissions of your /var/www type:

    sudo chmod -R 755 /var/www

    Hope this helps someone.

  13. WPsite.net Reply

    September 10, 2013 at 9:33 AM

    Well done Jason! thanks for sharing with the community. Much appreciated.

  14. Tech Riff Reply

    October 5, 2013 at 11:28 PM

    Thank you so much. Even i called the Customer support of godaddy and they said that there is an issue with your coding.. hoo…. worst support.. thanx a lot dear..

  15. ABhishek Reply

    October 26, 2013 at 2:51 PM

    Really very thanks !

  16. Mark Rainbird Reply

    March 6, 2014 at 3:54 AM

    Thanks for this – it was the PHP Safe Mode setting that my host enforces by default which caused the problem.

    • WPsite.net Reply

      March 6, 2014 at 3:41 PM

      Thanks for letting us know. PHP Safe Mode on which host?

  17. Lucas Reply

    June 16, 2014 at 9:59 AM

    Nice!

    Other possibility:

    Lack of disk space on the server.

  18. Henry Reply

    June 24, 2014 at 11:36 AM

    I have recently come across your blog as I had the very same problem with my website transfer obviuosly it is still left unresolved and awaiting tech support. However I have noticed your blog goes back to 2012. Now the current wordpress version is 3.9.1 and I can’t see the #1 option where I could replace label in the Settings > Media

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>