无法在 Wordpress 的 wp-content/uploads 中创建目录

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

Unable to create directory in wp-content/uploads in Wordpress

wordpressfile-uploadpermissionscentosimage-uploading

提问by Aasim Hussain Khan

I am not able to upload any images to the Media section. I get this error message:

我无法将任何图像上传到媒体部分。我收到此错误消息:

"Unable to create directory wp-content/uploads/2015/05. Is its parent directory writable by the server?"

“无法创建目录 wp-content/uploads/2015/05。服务器是否可以写入其父目录?”

I tried changing the permissions, gave full access 777 to both uploads, and wp-content directory but this didn't help.

我尝试更改权限,为上传和 wp-content 目录提供了 777 的完全访问权限,但这没有帮助。

I tried changing the owners to apache : apache for /wordpress/wp-content, but that hasn't helped either.

我尝试将所有者更改为 apache:/wordpress/wp-content 的 apache,但这也无济于事。

upload_path is set to wp-content/uploads in option-media.php. Still it is not working.

upload_path 在 option-media.php 中设置为 wp-content/uploads。它仍然不起作用。

Tried defining upload path define(UPLOADS, 'wp-content/uploads');No Help.

尝试定义上传路径define(UPLOADS, 'wp-content/uploads');没有帮助。

(server: centos)

(服务器:centos)

Someone, please help!!!

有人请帮忙!!!

-Thanks in advance.

-提前致谢。

回答by Aasim Hussain Khan

Debian like:

Debian 喜欢:

chown -R www-data:www-data /var/www/{yourpath}/wp-content/uploads

回答by MRMorrell

I was having a similar problem after migrating from a development site to a production site. It turned out that the message is deceptive. Check Settings, Media. Verify the directory for media is accurate for the current site. If the site was migrated, the directory listed still be from the old site and may need to be updated.

从开发站点迁移到生产站点后,我遇到了类似的问题。事实证明,该消息具有欺骗性。检查设置,媒体。验证当前站点的媒体目录是否准确。如果站点已迁移,则列出的目录仍来自旧站点,可能需要更新。

回答by Andaramis

Change permissions on the /wp-content directory to 0775 and try it again.

将 /wp-content 目录的权限更改为 0775 并重试。

sudo chmod 0775 {yourpath}/wp-content/uploads

If it fails, change the permissions to 0777 and try again.

如果失败,请将权限更改为 0777 并重试。

sudo chmod 0777 {yourpath}/wp-content/uploads

Once it is successful, be sure to return the permissions on /wp-content to whatever they were when you started.

一旦成功,请确保将 /wp-content 上的权限恢复为您开始时的任何权限。

You may also want to put the permissions back on any other files you changed while attempting to resolve the issue.

您可能还希望在尝试解决问题时将权限放回您更改的任何其他文件。

More options you can find here: https://www.tipsandtricks-hq.com/how-to-fix-the-unable-to-create-directory-error-in-wordpress-5264

您可以在此处找到更多选项:https: //www.tipsandtricks-hq.com/how-to-fix-the-unable-to-create-directory-error-in-wordpress-5264

Reggards

问候

回答by sasa

If this error is showed after migrating wordpress to new server check upload path in: settings->media->Store uploads in this folder

如果在将 wordpress 迁移到新服务器后显示此错误,请检查上传路径:settings->media->Store uploads in this folder

default value is wp-content/uploads.

默认值为 wp-content/uploads。

Probably you have old path.

可能你有老路。

回答by tussa33

Go to wp-admin/options.php
Under upload_pathreplace with exactly wp-content/uploads(no quotes, no extra slashes)
That worked for me after I had tried to all other solutions for days.

转到wp-admin/options.php
Underupload_path完全替换wp-content/uploads(没有引号,没有额外的斜线)
在我尝试了所有其他解决方案几天后对我有用。

回答by RyanLei

I tried all the solutions from How to Fix the Unable to create directory Error in WordPressin my Centos7. But it won't work.

我 在 Centos7 中尝试了How to Fix the Unable to create directory Error in WordPress中的所有解决方案。但它不会工作。

Then I found some useful message in /var/log/audit/audit.log

然后我在 /var/log/audit/audit.log 中发现了一些有用的消息

type=AVC msg=audit(1495357844.782:604): avc: denied { write } for pid=2721 comm="httpd" name="wp-content" dev="dm-5" ino=1074299184 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:etc_runtime_t:s0 tclass=dir type=SYSCALL msg=audit(1495357844.782:604): arch=c000003e syscall=83 success=no exit=-13 a0=7fffba9c62c0 a1=1ff a2=8 a3=5 items=0 ppid=1556 pid=2721 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)

type=AVC msg=audit(1495357844.782:604): avc: 拒绝 { write } for pid=2721 comm="httpd" name="wp-content" dev="dm-5" ino=1074299184 scontext=system_u:system_r: httpd_t:s0 tcontext=unconfined_u:object_r:etc_runtime_t:s0 tclass=dir type=SYSCALL msg=audit(1495357844.782:604): arch=c000003e syscall=83 success=no exit=-13 a016c=3cff =5 项=0 ppid=1556 pid=2721 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=429549672d " exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)

Check the file infomation : ls -Z /data/web/wordpress

检查文件信息: ls -Z /data/web/wordpress

Found that SELinux prevented Httpd to access the files. So you can disable the SELinux, or modify the file context: chcon -R --type=httpd_sys_rw_content_t /data/web/wordpress . And it works.

发现 SELinux 阻止了 Httpd 访问文件。所以你可以禁用 SELinux,或者修改文件上下文: chcon -R --type=httpd_sys_rw_content_t /data/web/wordpress 。它有效。

回答by zfd

I have managed to solve this by updating the reference to Settings Media Store uploads folder.

我已经通过更新对设置媒体商店上传文件夹的引用来解决这个问题。

Go to WordPress admin -> Settings -> Media, and update Store uploads in this folderoption with what is in your public_htmlhosting account.

转到 WordPress 管理员 -> 设置 -> 媒体,然后Store uploads in this folder使用您的public_html主机帐户中的内容更新选项。

/home/<base_folder_name>/public_html/wp-content/uploads

For me the <base_folder_name>was different than what was in the hosting account.

对我来说,<base_folder_name>这与托管帐户中的不同。

回答by rajatsaurastri

"The uploaded file could not be moved to wp-content/uploads/2015/05."

“上传的文件无法移动到 wp-content/uploads/2015/05。”

This error comes because of insufficient permission to your user on to the server.

出现此错误是因为您的用户对服务器的权限不足。

One Quick and dirty way to solve this error is to set 777 permission but some time it may not also work.

解决此错误的一种快速而肮脏的方法是设置 777 权限,但有时它可能也不起作用。

Follow this link this will help you 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/

Thanks

谢谢

回答by Ruwantha

Try following. Make sure {yourpath} is replaced with correct path

尝试跟随。确保 {yourpath} 替换为正确的路径

Creates upload directory with super user permission

使用超级用户权限创建上传目录

sudo mkdir -p /var/www/{yourpath}/wp-content/uploads

Change ownership to the current user

将所有权更改为当前用户

sudo chown -R $USER:$USER /var/www/{yourpath}/wp-content/uploads

回答by Dilip Raj Baral

This is sometimes an issue with file and directory ownership than permissions. Find out the user the php code is executing as using phpinfo()page.

这有时是文件和目录所有权而非权限的问题。找出正在使用phpinfo()页面执行 php 代码的用户。

Once you know the system user, make sure the FTP account you are using is configured to upload the files as that user. If it has been uploaded using different user, use chownto change the ownership of the base path to match the user.

一旦您知道系统用户,请确保您使用的 FTP 帐户配置为以该用户身份上传文件。如果已经使用不同的用户上传,则使用chown更改基本路径的所有权以匹配用户。

For example:

例如:

$ sudo chown -R <user> /path/to/public_html