i have done this: but it is not showing banner image: step1.


$fieldset->addField('banner_image', 'file', array(
          'label'     => Mage::helper('pictos')->__('Banner Image'),
          'required'  => false,
          'name'      => 'banner_image',


if(isset($_FILES['banner_image']['name']) and (file_exists($_FILES['banner_image']['tmp_name']))) {
  try {
    $uploader = new Varien_File_Uploader('banner_image');

    // setAllowRenameFiles(true) -> move your file in a folder the magento way
    // setAllowRenameFiles(true) -> move your file directly in the $path folder

    $path = Mage::getBaseDir('media') . DS .blog. DS ;

    $uploader->save($path, $_FILES['banner_image']['name']);

    $data['banner_image'] = $_FILES['banner_image']['name'];
  }catch(Exception $e) {

else {      

    if(isset($data['banner_image']['delete']) && $data['banner_image']['delete'] == 1)
        $data['image_main'] = '';

step three:

    'VARCHAR(255) NULL'

in frontend i call banner image like this:

        <div class="banner_area">
<?php $imageUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'/blog/'.$this->getpost()->getBannerImage();?>
            <img src="<?php echo $imageUrl;?>" alt="<?php echo $this->getpost()->getBannerImage();?>">

but no result


I can see one thing straight off you have your path set wrong in your controller.

 $path = Mage::getBaseDir('media') . DS .blog. DS ;

should be

$path = Mage::getBaseDir('media') . DS .'blog'. DS ;
  • Hi, eirik sorry .. $path = Mage::getBaseDir('media') . DS .'blog'. DS ; i have done this too ... but there is no result ... is there any issue with file permission with magento skin folder i don't see any folder with name blog in my skin images directory... but in media folder there is a folder for blog with but there is no image which i save from admin of my module .... – user2366074 May 19 '17 at 5:57
  • Inside the database table for the blog post. What is it saving the image name as? Also ensure the images don't have spaces/special characters in their names. – Eirik May 19 '17 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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