cancel
Showing results for 
Search instead for 
Did you mean: 

When I upload an image, Magento creates with 770 permission. How to change that behaviour?

When I upload an image, Magento creates with 770 permission. How to change that behaviour?

Hello,

 

I have a problem that I could not find a solution.

 

When I upload a file, by mean of the Magento backend, both the folders, and images under media directory are created using 770 permissions.

 

How can I change that so that folders are created with 775 permissions and files with 644?

 

Since website runs under apache user, I need the files to be able to be read by others.

 

Any help will be appreciated

Thanks

Jaime

2 REPLIES 2

Re: When I upload an image, Magento creates with 770 permission. How to change that behaviour?

I have found the solution for this.

 

I have opened the file /vendor/magento/framework/Filesystem/DriverInterface.php and modified constants WRITEABLE_DIRECTORY_MODE and WRITEABLE_FILE_MODE to be 0775 and 664 respectively.

 

Since the main problem was solved, the Magento bug is other now. When I uploaded, for example, the logo of the site, the image file used the permissions WRITEABLE_DIRECTORY_MODE instead of WRITEABLE_FILE_MODE.

 

Any comments about this?

Regards
Jaime

Re: When I upload an image, Magento creates with 770 permission. How to change that behaviour?

Hi, 

 

I finally figured out the same problem, the products all showed up correctly in my (xampp) dev machine, when I moved it to a hosted solution only some images showed up, the rest were not there, if you clicked on the product page on some product the images showed and others did not.

 

Then I realized that as you navigated to the products for the very first time, magento created a new folder, lets say if you added a product to the cart, it will automatically create a small 70x70 images folder with permission 770 and it would not display on your site because of 770 permissions, now if you were to change it to 775, then it does not need to be done for any subsequent visits.

 

This is true for navigation to the main product page i.e. with a grid, individual product page, its zoomed image or the small image shown in the cart. 

 

Since I am working with a smaller number of higher dollar products, my temporary solution is to select each product, put it in the cart, so that all size images are created and then change the directory permissions. I am using Filezilla and choosing apply to all directories below

 

However I would also like to find out how to completely eliminate this issue and have Magento create the folders with correct permissions in the first place.