马根托。目标文件夹不可写或不存在

发布于 2024-10-19 05:17:49 字数 579 浏览 3 评论 0原文

嘿,我遇到了以下问题,请帮忙。

尝试将图像添加到产品时,我收到“目标文件夹不可写..”,但所有所需文件夹的权限为777!我删除了服务器上的所有文件,没有触及数据库,使用新数据库从头开始重新安装 Magento,一切正常。 但是当我切换到以前的数据库(更改 local.xml 中的设置)时,错误再次出现。

数据库如何影响文件夹权限?

更新:

非常感谢,我们发现 Magento 从这个方法跳转

public function getBaseMediaUrl()
{
   return Mage::getBaseUrl('media') . 'catalog/product';
}

到以下方法:

public function getBaseTmpMediaUrl()
{
        return Mage::getBaseUrl('media') . 'tmp/catalog/product';
}

有谁知道为什么以及如何???

Hey I'm stuck with the following problem, plz help.

I get "Destination folder is not writable.." when trying to add an image to a product, but the permission for all needed folders is 777! I had deleted all files on server, didn`t touch DB, reinstalled Magento from scratch with new DB, and everything is OK.
But when I switched to previous DB (change settings in the local.xml) the bug appeared again.

How can the DB impact the folder permissions?

UPDATE:

Thanx a lot, we found out that Magento jump from this method:

public function getBaseMediaUrl()
{
   return Mage::getBaseUrl('media') . 'catalog/product';
}

to the following method:

public function getBaseTmpMediaUrl()
{
        return Mage::getBaseUrl('media') . 'tmp/catalog/product';
}

Does anybody know why and how????

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

尴尬癌患者 2024-10-26 05:17:49

Magento 代码库中只有一个位置使用该错误语言。

File: lib/Varien/File/Uploader.php
...
if( !is_writable($destinationFolder) ) {
    throw new Exception('Destination folder is not writable or does not exists.');
}   
...

在上面添加一些临时调试代码这

...
if( !is_writable($destinationFolder) ) {
    Mage::Log($destinationFolder);
    //or
    var_dump($destinationFolder);   
    throw new Exception('Destination folder is not writable or does not exists.');
}   
...

将使您知道 Magento 想要写入但不能写入的确切文件夹。检查这个文件夹,你会发现它不可写。查看 is_writable 上的边缘情况也可能有助于阐明该主题。

There's only one spot in the Magento code base that uses that error language.

File: lib/Varien/File/Uploader.php
...
if( !is_writable($destinationFolder) ) {
    throw new Exception('Destination folder is not writable or does not exists.');
}   
...

Add some temporary debugging code right above this

...
if( !is_writable($destinationFolder) ) {
    Mage::Log($destinationFolder);
    //or
    var_dump($destinationFolder);   
    throw new Exception('Destination folder is not writable or does not exists.');
}   
...

This will let you know the exact folder Magento wants to write to, but can't. Examine this folder, and you'll find it's not writable. Reviewing the edge cases on is_writable may also shed some light on the subject.

不羁少年 2024-10-26 05:17:49

转到:lib/Varien/File/Uploader.php

临时更改以下代码并尝试上传图像。现在在错误消息中您可以看到文件夹路径。
在文件夹路径中,您必须授予文件权限 777,它将正常工作。错误解决后,将代码恢复到原来的状态。

if( !is_writable($destinationFolder) ) {
    var_dump($destinationFolder);   
    throw new Exception(''.$destinationFolder.'Destination folder is not writable or does not exists.');
} 

Goto : lib/Varien/File/Uploader.php

Temporary change the following code and try to upload image. Now in error message you can see folder path.
In folder path you have to give file permission 777 and it will work as normal. After the error is resolved revert your code to as it wass.

if( !is_writable($destinationFolder) ) {
    var_dump($destinationFolder);   
    throw new Exception(''.$destinationFolder.'Destination folder is not writable or does not exists.');
} 
谁把谁当真 2024-10-26 05:17:49

我在 Magento 中上传图像时遇到以下错误,然后我执行了以下步骤,这对我有用。

Cd /var/www/

chmod 755 -R /html
chown apache:apache -R /html
setenforce 0

然后重新启动阿帕奇..

I got the below error while uploading images in Magento then I did the below steps and that worked for me.

Cd /var/www/

chmod 755 -R /html
chown apache:apache -R /html
setenforce 0

then restart apache ..

几度春秋 2024-10-26 05:17:49

Magento 2

这是 Magento 2 中的文件,错误来自于:

vendor/magento/framework/File/Uploader.php

在第 256 行,您可以暂时将此代码放置到获取不可写/不存在的文件夹:

if( !is_writable($destinationFolder) ) {
    error_log($destinationFolder);        
    // or
    // throw new Exception('Destination folder is not writable or does not exists.');
    throw new Exception($destinationFolder);
} 

否则,您可以检查您是否拥有这些文件夹,并且这些文件夹可由网络服务器写入:

  • pub/media/catalog/
  • pub/media/catalog/category
  • pub/media/catalog/product
  • pub/media/images
  • pub/media/wysiwyg/

Magento 2

This is the file in Magento 2 where the error come from:

vendor/magento/framework/File/Uploader.php

At line 256 you can temporarily place this code to get the unwritable/unexisting folder:

if( !is_writable($destinationFolder) ) {
    error_log($destinationFolder);        
    // or
    // throw new Exception('Destination folder is not writable or does not exists.');
    throw new Exception($destinationFolder);
} 

Otherwise you can check you have these folders and that are writable by the web server:

  • pub/media/catalog/
  • pub/media/catalog/category
  • pub/media/catalog/product
  • pub/media/images
  • pub/media/wysiwyg/
我偏爱纯白色 2024-10-26 05:17:49

这可能是 Plesk 管理部门颁发的过期证书(这是我的情况)。

我尝试了上面的步骤,但没有成功。从那里我尝试通过 FileZilla 访问文件以立即向所有文件夹授予权限,因此出现有关证书过期的错误消息。它不是商店本身的 SSL 证书,而是 Plesk 的管理。我创建了一个新的自签名证书,应用了其 Plesk 管理,一切都恢复正常。

这对我有用。我在这里留下我的贡献。

祝你好运

It may be the expired certificate from the Plesk administration (it was my case).

I tried the steps above, but it did not work. From there I tried to access the files through FileZilla to give the permissions at once to all folders, hence an error message about the expired certificate. It is not the SSL certificate of the store itself, but the administration of Plesk. I created a new self-signed certificate, applied its Plesk administration and everything went back to normal.

This worked for me. I leave here my contribution.

Good luck

梅窗月明清似水 2024-10-26 05:17:49

我遇到了同样的问题:

在此处输入图像描述

登录到 SSH:

通过运行以下命令授予媒体文件夹权限:

 cd public_html/media
 find . -type d -exec chmod 777 {} \;

I had the same problem:

enter image description here

Sign in to your SSH:

Give media folder permissions through run this command:

 cd public_html/media
 find . -type d -exec chmod 777 {} \;
可遇━不可求 2024-10-26 05:17:49

更改媒体文件夹的权限后,我的问题得到解决。只需找到服务器上的媒体文件夹,右键单击 -> 更改权限 -> 将文件夹权限设置为 777。

权限对话框

My issue is solved after changing the permissions of the media folder. Just go locate the media folder on your server, right click->change permissions->set value 777 for folder permissions.

Permissions dialog

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文