23
votes

I am working on a WordPress website from 2 months and I have uploaded many images before but I am getting an error when uploading image and I am facing this issue after new year :- The uploaded file could not be moved to wp-content/uploads/2015/01.

there is Screenshot below:- The uploaded file could not be moved WordPress

13
Does this directory even exists?Rizier123
check permisions and the owner of the directoryviolator667
yes i have manually created the directory.Kesar Sisodiya
If you created the folder, chances are the webserver can't access it. Delete the folder and let the server create it automatically with the right permissions.ceejayoz
i dont know how to do that, can you explaine in answer ?Kesar Sisodiya

13 Answers

22
votes

This article explains and resolves the issue very well: http://2surge.com/how-to-fix-the-uploaded-file-could-not-be-moved-to-wp-content-error-message

The basic premise is that the identity of the process running your httpd / apache / web server thread must have write access to your upload directory.

To resolve the issue:

  1. Check which account your webserver is running under

    Update: On Unix use...

    ps aux | egrep '(apache|httpd)'

    ... this will show a list of processes for the web server along with the identity of the process under which its running e.g."nobody"

    nobody 8718 0.1 0.4 1332864 17180 ? Sl 17:11 0:06 /usr/local/apache/bin/httpd -k start -DSSL

  2. Update the permission of the upload directory to allow that account to write to it.

    Update: On Unix, you can use...

    chown -R nobody /<path to upload directory>/wp-content/upload/

    You can also amend permissions for this account (at the rquired location) to ensure it has write permissions using chmod or filezilla and cascade the changes to the directories as necessary.

Check out the linked article for a detailed breakdown. Hope that helps! :)

14
votes

This works for me.

$ sudo chown -R _www uploads/
$ sudo chmod -R g+w uploads/

I am assuming you are in the wp-content directory.

10
votes

You just need to give permission to PHP to write in the uploads folder, this worked for me:

sudo chown -R www-data <path>/wp-content/uploads
6
votes

I have searched and found that the problem is from server provider.

Typically, all files should be owned by your user (ftp) account on your web server, and should be writable by that account. On shared hosts, files should never be owned by the webserver process itself (sometimes this is www, or apache, or nobody user).

Any file that needs write access from WordPress should be owned or group-owned by the user account used by the WordPress (which may be different than the server account). For example, you may have a user account that lets you FTP files back and forth to your server, but your server itself may run using a separate user, in a separate usergroup, such as dhapache or nobody. If WordPress is running as the FTP account, that account needs to have write access, i.e., be the owner of the files, or belong to a group that has write access. In the latter case, that would mean permissions are set more permissively than default (for example, 775 rather than 755 for folders, and 664 instead of 644).

You can see here how to change file permission..

4
votes

If you're using something with SELinux (like Fedora or CentOS), you'll also need to set SELinux permissions. Assuming that your directory is called uploads (for example)

chcon -R -t httpd_sys_rw_content_t uploads

This will set uploads and everything under it to be uploadable to the web server user

2
votes

it probably doesn't have the permissions to create /uploads/2015

Check if that folder exists, if it does, then check if /uploads/2015/1/ exists.

permissions:

chmod 755 /uploads/2015/1/
chown www-data:www-data /uploads/2015/1/

These folders should have the same permissions as the /uploads/ folder. Also check the error_log, because it should show you exactly what folder is causing the issue.

1
votes

This works for me

sudo chown -R www-data html

Assuming current directory is www

Ubuntu 16.04, Apache2

0
votes

I had this problem as well and found out it was because the hosting account's disk quota was exceeded.

I found that there was an old script that was logging errors and the error log had gotten so big it filled the available quota.

I finally figured it out when I attempted to create a new directory using FTP and the server response was "Disk quota exceeded."

0
votes

I got this error on a cPanel hosting account, where the disk quota (for the account) was not an issue. After delving into it for a while, I found that cPanel's "Select PHP Version" tool was set to v7.1 but multiple WordPress diagnosis tools were detecting v5.6 was actually running, and they also detected file system issues.

The File Manager tool in cPanel showed all the permissions were correct, and the folders were writeable.

One of the diagnosis tools I used was part of the Wordfence plugin. It was available on the Dashboard menu at Wordfence > Tools > Diagnostics (tab).

I reported the issue to the hosting company, and it appeared to fix itself overnight (the person who responded to my support ticket indicated they didn't fix anything). I think it's likely it was a symptom of a problem that affected multiple hosting accounts, and somebody else within the hosting company probably detected it and fixed it.

In case others encounter a similar issue, I hope this answer helps them spend less time trying to track it down. Once I discovered the incorrect PHP version appeared to be running, I figured it was probably not something I could fix with only cPanel access.

0
votes

This will happen when you migrate a WP site to a different server.

Problem is the ownership.

Run this in a terminal:

chown -R <site-user-name> /home/<site-directory>/public_html

z

0
votes

There are multiple reason because of this such error arise.

Main problem is folder permission.

wp-content/upload/

Folder permission must be 775 or 664.

Other solution if the error not get resolved try below

Go to Cpanel and your website folder or by using FTP.

Then you will get wp-config.php {This file available on root folder}

In that do below change

Open the wp-config.php file and add the following code:
define( 'UPLOADS', 'wp-content/uploads' );
before below line
require_once(ABSPATH . 'wp-settings.php');

I hope this will help. It's help me on Plesk Hosting.

-1
votes
  • Open you xampp
  • Click on explore
  • Double click on folder of your project
  • Click on "Get Info" in options list
  • Unlock the locker in the right bottom side by entering your password
  • Then change permissions to read and write
  • MOST IMPORTANT POINT, remember to click on the bottom left conner dropdown and select Apply to all
  • There it will work.
  • Watch how it is done in this video
  • Thank me later How to fix xampp permission problem on mac
-11
votes

Changing directory permission to 777 helped me.