wordpress 上传的文件无法移动到 wp-content/uploads
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19020186/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The uploaded file could not be moved to wp-content/uploads
提问by Wang'l Pakhrin
I am trying to upload pictures in WordPress but I get this error:
我正在尝试在 WordPress 中上传图片,但出现此错误:
The uploaded file could not be moved to wp-content/uploads.
上传的文件无法移动到 wp-content/uploads。
I am running it in localhost but the answers I have found are to change the folder permissions to 777 on the server.
我在 localhost 中运行它,但我找到的答案是将服务器上的文件夹权限更改为 777。
I tried making an uploads folder myself, but it's of no use and there is no option to change the folder permissions to anything except read and write.
我尝试自己制作一个上传文件夹,但它没有用,并且没有选项可以将文件夹权限更改为除读写之外的任何内容。
I'm using XAMPP on Mac OS X; I'm new to WordPress - how can I fix this?
我在 Mac OS X 上使用 XAMPP;我是 WordPress 的新手 - 我该如何解决这个问题?
采纳答案by Danny Beckett
Provided that your wordpress directory is "owned" by the correct user, you should see your problem resolved if you set the permissions to 755.
假设您的 wordpress 目录由正确的用户“拥有”,如果您将权限设置为 755,您应该会看到问题已解决。
Log on to your server, and cd
to wp-content
, then run:
登录到您的服务器,cd
以wp-content
,然后运行:
chmod 755 uploads
回答by myol
It is most likelya 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;
这很可能是权限问题。通过导航到站点wp-content
所在服务器上的站点文件夹,查找在站点上运行的用户进程。然后输入这个;
ps aux | egrep '(apache|httpd)'
Ignore root, but look at the other users
忽略 root,但看看其他用户
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 wasapache (usually www-data). Finally change the users of the uploads
folder to this user;
对我来说,它实际上是apache(通常是 www-data)。最后把uploads
文件夹的用户改成这个用户;
sudo chown -R apache:apache uploads
(make sure you are in the directory above the uploads folder when running this command)
(运行此命令时,请确保您位于uploads文件夹上方的目录中)
This will permit the correctuser to access this directory using the correctaccess permissions of 755.
这将允许正确的用户使用755的正确访问权限访问此目录。
By using the dreadful '777' advice of others, you are simply allowing the correct user to access the directory assigned to the incorrectuser - as well as anyone else who can access that directory!
通过使用其他人可怕的“777”建议,您只是允许正确的用户访问分配给错误用户的目录- 以及可以访问该目录的任何其他人!
回答by UserK
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
将所有权限授予所有者,但仅授予其他用户读取和执行权限
回答by Chris Pickford
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.
对于登陆这里但使用 Windows / IIS 平台的任何人,您都可以通过Everyone
为您的wp-content\uploads
目录组授予修改权限来实现相同的目的。
回答by rok
another possible reason is wrong owner and group of uploads
folder.
另一个可能的原因是错误的所有者和uploads
文件夹组。
try
尝试
chown -R _www:_www wp-content/uploads
assuming your apache group and owner is _www
假设您的 apache 组和所有者是 _www