Magento – Accessing files at media directory

ce-1.9.0.1mediaurl

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?

Best Answer

It depends from where you want to call that access from; there's 2 possibilities:

  1. from within the Magento Administration - say, a CMS page or a Block. There, you can refer to the 'media' directory via

  2. from a template-file (phtml)

    1. refer to the skin directory:

      <img src="<?php echo $this->getSkinUrl('images/filename.jpg')?>" 
      
    2. 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

Related Topic