php 上传的文件无法移动到 wp-content/uploads/2015/01。图片上传问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27845139/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:33:26  来源:igfitidea点击:

The uploaded file could not be moved to wp-content/uploads/2015/01. issue on image upload

phpwordpress

提问by Kesar Sisodiya

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.

我从 2 个月开始在 WordPress 网站上工作,我之前上传过很多图片,但上传图片时出现错误,新年后我遇到了这个问题:- 上传的文件无法移动到 wp-content/uploads /2015/01。

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

下面有截图:- 上传的文件无法移动 WordPress

采纳答案by Kesar Sisodiya

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

通常,所有文件都应该归您的 Web 服务器上的用户 (ftp) 帐户所有,并且应该可由该帐户写入。在共享主机上,文件永远不应该归网络服务器进程本身所有(有时是 www、apache 或 nobody 用户)。

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

任何需要 WordPress 写访问权限的文件都应该由 WordPress 使用的用户帐户(可能与服务器帐户不同)拥有或归组所有。例如,您可能有一个用户帐户,允许您将 FTP 文件来回发送到您的服务器,但您的服务器本身可能使用单独的用户在单独的用户组中运行,例如 dhapache 或 nobody。如果 WordPress 作为 FTP 帐户运行,则该帐户需要具有写入权限,即成为文件的所有者,或属于具有写入权限的组。在后一种情况下,这意味着权限设置得比默认值更宽松(例如,文件夹是 775 而不是 755,而文件夹是 664 而不是 644)。

You can see here how to change file permission..

您可以在此处查看如何更改文件权限..

回答by Matt Woodward

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

这篇文章很好地解释和解决了这个问题: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.

基本前提是运行你的httpd/apache/web服务器线程的进程的身份必须对你的上传目录有写权限。

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.

  1. 检查您的网络服务器在哪个帐户下运行

    更新:在 Unix 上使用...

    ps aux | egrep '(apache|httpd)'

    ...这将显示 Web 服务器的进程列表以及运行它的进程的标识,例如“nobody”

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

  2. 更新上传目录的权限以允许该帐户对其进行写入。

    更新:在 Unix 上,您可以使用...

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

    您还可以修改此帐户的权限(在所需位置)以确保它具有使用 chmod 或 filezilla 的写权限,并根据需要将更改级联到目录。

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

查看链接的文章以获取详细的分类。希望有帮助!:)

回答by Jhelaine De Leon

This works for me.

这对我有用。

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

I am assuming you are in the wp-contentdirectory.

我假设你在wp-content目录中。

回答by Commercial Suicide

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

您只需要授予 PHP 在uploads文件夹中写入的权限,这对我有用:

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

回答by Alex

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

它可能没有创建 /uploads/2015 的权限

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

检查该文件夹是否存在,如果存在,则检查 /uploads/2015/1/ 是否存在。

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.

这些文件夹应具有与 /uploads/ 文件夹相同的权限。还要检查 error_log,因为它应该准确显示导致问题的文件夹。

回答by Nuwan Sameera

This works for me

这对我有用

sudo chown -R www-data html

Assuming current directory is www

假设当前目录是 www

Ubuntu 16.04, Apache2

Ubuntu 16.04,Apache2

回答by webdoc

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

当我尝试使用 FTP 创建一个新目录并且服务器响应是“超出磁盘配额”时,我终于弄明白了。

回答by Highly Irregular

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.

我在 cPanel 托管帐户上遇到此错误,其中磁盘配额(该帐户)不是问题。钻研了一会,发现cPanel的“选择PHP版本”工具设置为v7.1,但多个WordPress诊断工具检测到v5.6实际运行,还检测到文件系统问题。

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

cPanel 中的文件管理器工具显示所有权限都正确,并且文件夹是可写的。

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

我使用的诊断工具之一是 Wordfence 插件的一部分。它位于 Wordfence > 工具 > 诊断(选项卡)的仪表板菜单上。

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.

如果其他人遇到类似的问题,我希望这个答案可以帮助他们花更少的时间来追踪它。一旦我发现错误的 PHP 版本似乎正在运行,我认为这可能不是我只能通过 cPanel 访问来修复的问题。

回答by Machavity

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)

如果您使用 SELinux(如 Fedora 或 CentOS),您还需要设置 SELinux 权限。假设您的目录被调用uploads(例如)

chcon -R -t httpd_sys_rw_content_t uploads

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

这将设置uploads及其下的所有内容都可以上传到网络服务器用户

回答by Master Ace

Changing directory permission to 777 helped me.

将目录权限更改为 777 对我有帮助。