The uploaded file could not be moved to wp-content/uploads

為{幸葍}努か 提交于 2019-11-29 06:20:59

Open the Terminal app, cd to wp-content, and run:

chmod 755 uploads

It is most likely a permissions issue. Find the user processes running on the site by navigating to your sites wp-content folder on the server your site is on. Then type this;

ps aux | egrep '(apache|httpd)'

Ignore root, but look at the other users

root      2507  0.0  0.3 423820 14328 ?        Ss   Aug04   0:51 /usr/sbin/httpd
apache    4653  0.5  1.9 483900 77252 ?        S    16:27   0:14 /usr/sbin/httpd
apache    4654  0.5  2.1 500160 84912 ?        S    16:27   0:13 /usr/sbin/httpd
apache    4656  0.8  2.0 484708 78712 ?        S    16:27   0:21 /usr/sbin/httpd
...

For me it actually was apache (usually www-data). Finally change the users of the uploads folder to this user;

sudo chown -R apache:apache uploads

(make sure you are in the directory above the uploads folder when running this command)

This will permit the correct user to access this directory using the correct access permissions of 755.

By using the dreadful '777' advice of others, you are simply allowing the correct user to access the directory assigned to the incorrect user - as well as anyone else who can access that directory!

I would recommend, for security's sake, instead of

sudo chmod 777 uploads

which gives permissions (read, write, execute) to the user who owns the folder (the root), to other users in the file's Group and to other users not in the file's group (anyone else).

sudo chmod 755 uploads

which gives all permissions to the owner, but only read and execute permissions to the other users

For anyone who has landed here but using a Windows / IIS platform then you can achieve the same thing by giving modify permissions to the Everyone group for your wp-content\uploads directory.

another possible reason is wrong owner and group of uploads folder.

try

chown -R _www:_www wp-content/uploads

assuming your apache group and owner is _www

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!