I uploaded additional files for products. They get stored in media folder in Magento root directory. How can I access files stored at media folder in Magento root folder? Should I use a method for accessing files outside Root directory or simply involve a direct access code in php?
1 Answer
It depends from where you want to call that access from; there's 2 possibilities:
from within the Magento Administration - say, a CMS page or a Block. There, you can refer to the 'media' directory via
from a template-file (phtml)
refer to the skin directory:
<img src="<?php echo $this->getSkinUrl('images/filename.jpg')?>"
refer to the media directory:
<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); ?>
There's also plenty of sources:
See Magento-Forum or stanleytips.com for starters
-
So I should use Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); where URL_TYPE_MEDIA is the path to the media directory? Jul 11, 2014 at 8:09
-
If you work with a template file (*.phtml) - yes, that's what I would try first.– JohannesJul 11, 2014 at 8:12