Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento. Destination folder is not writable or does not exists

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????

like image 228
slavig Avatar asked Feb 23 '11 12:02

slavig


1 Answers

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.

like image 86
Alan Storm Avatar answered Sep 28 '22 08:09

Alan Storm