slavig slavig - 3 months ago 27
PHP Question

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

Answer

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.

Comments