slavig
slavig

Reputation: 339

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

Upvotes: 8

Views: 26335

Answers (7)

Mayuri Khedekar
Mayuri Khedekar

Reputation: 5

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

Upvotes: -2

Said Erraoudy
Said Erraoudy

Reputation: 1559

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 {} \;

Upvotes: 0

Cledson Silva
Cledson Silva

Reputation: 1

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

Upvotes: 0

Rizwan Basheer
Rizwan Basheer

Reputation: 137

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

Upvotes: 1

Andrea
Andrea

Reputation: 16560

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/

Upvotes: 0

Niranjan Gondaliya
Niranjan Gondaliya

Reputation: 216

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.');
} 

Upvotes: 3

Alana Storm
Alana Storm

Reputation: 166086

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.

Upvotes: 17

Related Questions