1

I know it's not recommended but I want to upload product images to any folder in my web server's root directory instead of magento's media folder.

<upload_dir config="system/filesystem/media" scope_info="1">sales/store/logo</upload_dir>

The base image upload path is set with the config attribute (system/filesystem/media above). I've updated system config value Base Media URL to http::/127.0.0.1/external. But I don't see my product images being saved in http::/127.0.0.1/external folder once image is uploaded and product is saved.

Can anyone share where is the actual upload image code present? I've checked in Mage_Catalog_Model_Product_Attribute_Backend_Media::addImage() by doing Mage::log() but I think this function is not being called?

2 Answers 2

5

The easiest way to do this is to symlink the media directory or the corresponding subfolder to another location on disk:

ln -s media/catalog/product/ /mnt/my/huge/fileserver/location

1
  • good trick @philwinkle
    – Amit Bera
    Nov 30, 2015 at 20:05
0

If your environment is chrooted this solution won't work well.

As the apache / nginx process and php-fpm will view paths as absolute, but your CLI will not be able to see the second path in /mnt thus giving some issues.

An alternative would be a bind mount

In your /etc/fstab you can use

/mnt/md3/<my_storage>/pub/media /<path_to_docroot>/pub/media none bind,user=<magento_owner> 0 0

This has a downside if your system relies on df to calculate disk size because the disk size will be appearing as the normal partitions size + the bind mount's size. You will be able to utilize the full space, just df will display wrong sizes and it can have potential issues in backup applications, elastic search (if it's hosted in the same server using the same partition)

I'm still looking for a better alternative myself

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.