cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple attribute not working for file and image input type in magento 1.9?

Multiple attribute not working for file and image input type in magento 1.9?

 

I want to take mutliple images from customer but the mutliple attribute is not taken by input control in magento.

$form->addField('images', 'image', array(
            'name' => "vendor[images[]]",
            'label' => 'Upload Image/Images',
            'class' => 'input-file',
            'multiple'  => 'multiple',
                'after_element_html' => '<small>Hold ctrl and select images when multiple upload and size should be less than 1 MB.</small>',
            )           );

Suggest how can i taken multiple images from customer with single browse button.

I also create a new file to set multiple attribute for Image type, Below is the code :

class Ced_CsMarketplace_Block_Vendor_Registration_Helper_Image extends Varien_Data_Form_Element_Image{
//make your renderer allow "multiple" attribute
public function getHtmlAttributes(){
return array_merge(parent::getHtmlAttributes(), array('multiple'));
}
}

And Add this line in form.php file where I add fields :

$form = new Varien_Data_Form();
$form->addType('image', 'Ced_CsMarketplace_Block_Vendor_Registration_Helper_Image');

and In controller file when I print $_POST I get the below output :

Array
(
    [form_key] => tSUE56PLMUMKGXim
    [success_url] => 
    [error_url] => 
    [firstname] => Tanu
    [middlename] => Shree
    [lastname] => Vyas
    [email] => tanu@mailinator.com
    [is_vendor] => 1
    [vendor] => Array
        (
            [contact_number] => 23456214052
            [company_name] => tanu test cmp
            [company_address] => test location tanu
            [public_name] => test-store-tanu
            [shop_url] => test-str-tanu
            [company_reg_no] => R678
            [website] => http://tanu-test-store.com
            [images[] => buy_now1.png
        )

    [password] => XCp90w
    [confirmation] => XCp90w
)

Here Images[ ] display only single image, even I select Multiple but this show only one.

And $_FILES is empty, As I think because the field type is image.

Please suggest how can I save multiple images, I am able to select multiple image but only single image is displaying in post data.

3 REPLIES 3

Re: Multiple attribute not working for file and image input type in magento 1.9?

Hi @neha_

For multiple image upload you need to create custom renderer.

Please check this post it may help you Magento Custom Module: multiple Image Uploader in adminhtml form

---
Problem Solved Click Accept as Solution!:Magento Community India Forum

Re: Multiple attribute not working for file and image input type in magento 1.9?

I want multi-upload facility in front -end not in back-end, I already check this and add a new file in my block folder of my module :

class Ced_CsMarketplace_Block_Vendor_Registration_Helper_Image extends Varien_Data_Form_Element_Image{
//make your renderer allow "multiple" attribute
public function getHtmlAttributes(){
return array_merge(parent::getHtmlAttributes(), array('multiple'));
}
}

 

Re: Multiple attribute not working for file and image input type in magento 1.9?

I used this but when I use print_r($_FILES) it returns empty array and in $_POST it return only one image, How can I get and save these multiple selected files.