25

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

11
  • Does this directory even exists?
    – Rizier123
    Jan 8, 2015 at 16:40
  • 3
    check permisions and the owner of the directory Jan 8, 2015 at 16:40
  • yes i have manually created the directory. Jan 8, 2015 at 16:41
  • 1
    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
    Jan 8, 2015 at 16:44
  • 1
    i dont know how to do that, can you explaine in answer ? Jan 8, 2015 at 16:47

14 Answers 14

25

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! :)

2
  • This is a bad solution, you should not give nobody ownership to any files or directories but rather you should change the user that is running the webserver process.
    – Omtara
    Jun 14, 2020 at 8:33
  • @Omtara - please note that the use of "nobody" was an example only, not a recommendation on the appropriate implementation of credentials. The focus of this answer was on the correct attribution of privileges to the account accessing the upload directory only. Please feel free to contribute to that answer. Jul 15, 2020 at 2:14
15

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.

0
11

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
0
6

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..

1
  • I am using an IIS service of hosting, so I do not know how to solve the problem. But, what is curious is that before I did not have any problem uploading photos to Wordpress. I cannot neither update Wordpress. But last weeks, I did not have any problem.
    – anrequete
    May 31, 2017 at 14:30
4

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

0
2

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.

4
  • 1
    I now uloads/2015/01 but please explaine what is chown www-data:www-data and where i can get the error_log Jan 8, 2015 at 16:51
  • you cannot assume that on his server www-data user is the right (correct) owner. Jan 8, 2015 at 16:51
  • 1
    Ok violator now i know, and what is error_log, where i can find it ? Jan 8, 2015 at 16:54
  • 2
    Maybe you should read something about permisions first - because you don't understand what is going on :) linux.com/learn/tutorials/… Jan 8, 2015 at 16:56
1

This works for me

sudo chown -R www-data html

Assuming current directory is www

Ubuntu 16.04, Apache2

0

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

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

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

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.

0

This solution is only for those who use the cPanel control panel, and you must test this for other panels like aaPanel, Directadmin and others ... Be sure to take a snapshot/checkpoint from your server before making changes.

Install the mod_suphp module through Easy Apache. After installation from the MultiPHP Manager section: Select suphp from the drop-down menu under the PHP Handler column And finally, apply the changes.

Test again and if necessary type the following commands:

/usr/local/cpanel/bin/rebuild_phpconf –current
-1
  • 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
-10

Changing directory permission to 777 helped me.

4
  • 6
    Don't do this. Setting 777 is almost never a good idea. Read more about it here: askubuntu.com/questions/20105/…
    – hlozancic
    Sep 19, 2017 at 14:39
  • 1
    It helped me that time and in my case security or any of that wasn't a necessity.
    – Master Ace
    Apr 30, 2018 at 1:14
  • This can not be recommended do not use this method Aug 4, 2020 at 0:31
  • NEVER EVER do this. Ever.
    – wickywills
    Sep 14, 2020 at 13:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.