php 马杰托。目标文件夹不可写或不存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5090689/
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
Magento. Destination folder is not writable or does not exists
提问by slavig
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.
尝试将图像添加到产品时,我收到“目标文件夹不可写..”,但所有所需文件夹的权限为777!我已经删除了服务器上的所有文件,没有接触数据库,用新数据库从头开始重新安装 Magento,一切正常。但是当我切换到以前的数据库(更改local.xml 中的设置)时,错误再次出现。
How can the DB impact the folder permissions?
数据库如何影响文件夹权限?
UPDATE:
更新:
Thanx a lot, we found out that Magento jump from this method:
非常感谢,我们发现 Magento 是从这个方法跳转的:
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????
有人知道为什么以及如何吗????
回答by Alan Storm
There's only one spot in the Magento code base that uses that error language.
Magento 代码库中只有一处使用该错误语言。
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_writablemay also shed some light on the subject.
这会让您知道 Magento 想要写入但不能写入的确切文件夹。检查这个文件夹,你会发现它是不可写的。查看is_writable上的边缘情况也可能会对该主题有所了解。
回答by Niranjan Gondaliya
Goto : lib/Varien/File/Uploader.php
转到: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.
临时更改以下代码并尝试上传图像。现在在错误消息中您可以看到文件夹路径。在文件夹路径中,您必须授予文件权限 777,它才能正常工作。解决错误后,将您的代码恢复原样。
if( !is_writable($destinationFolder) ) {
var_dump($destinationFolder);
throw new Exception(''.$destinationFolder.'Destination folder is not writable or does not exists.');
}
回答by Rizwan Basheer
I got the below error while uploading images in Magento then I did the below steps and that worked for me.
在 Magento 中上传图像时出现以下错误,然后我执行了以下步骤,这对我有用。
Cd /var/www/
chmod 755 -R /html
chown apache:apache -R /html
setenforce 0
then restart apache ..
然后重启apache..
回答by Cledson Silva
It may be the expired certificate from the Plesk administration (it was my case).
它可能是来自 Plesk 管理部门的过期证书(这是我的情况)。
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.
我尝试了上面的步骤,但没有奏效。从那里我尝试通过 FileZilla 访问文件以立即向所有文件夹授予权限,因此出现有关过期证书的错误消息。它不是商店本身的 SSL 证书,而是 Plesk 的管理。我创建了一个新的自签名证书,应用了它的 Plesk 管理,一切都恢复了正常。
This worked for me. I leave here my contribution.
这对我有用。我在这里留下我的贡献。
Good luck
祝你好运
回答by Said Erraoudy
回答by Mayuri Khedekar
回答by Andrea
Magento 2
Magento 2
This is the file in Magento 2 where the error come from:
这是 Magento 2 中错误来自的文件:
vendor/magento/framework/File/Uploader.php
vendor/magento/framework/File/Uploader.php
At line 256
you can temporarily place this code to get the unwritable/unexisting folder:
在行中,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);
}
Otherwise you can check you have these folders and that are writable by the web server:
否则,您可以检查您是否拥有这些文件夹并且可以由 Web 服务器写入:
pub/media/catalog/
pub/media/catalog/category
pub/media/catalog/product
pub/media/images
pub/media/wysiwyg/
pub/media/catalog/
pub/media/catalog/category
pub/media/catalog/product
pub/media/images
pub/media/wysiwyg/