I am working on magneto 1.7 version.In this I created a extension. Now, I need to upload multiple images from a form which I created. I have a browser button in a form Now I need to upload multiple images from that button in a single time.
Can anyone help me?
Below is my form:
protected function _prepareForm() {
$form = new Varien_Data_Form();
$this->setForm($form);
$fieldset = $form->addFieldset('book_form', array('legend' => Mage::helper('test')->__('Book Content')));
$fieldset->addField('title', 'text', array(
'label' => Mage::helper('test')->__('Title'),
'class' => 'required-entry',
'required' => true,
'name' => 'title[]',
));
$categoryArray = Mage::getSingleton('test/category')->getOptionArray();
$fieldset->addField('category_id', 'select', array(
'label' => Mage::helper('test')->__('Category'),
'required' => true,
'class' => 'required-entry',
'name' => 'category_id[]',
'values' => $categoryArray,
));
**$fieldset->addField('image', 'file', array(
'label' => Mage::helper('test')->__('Image'),
'name' => 'image[]',
'multiple' => 'multiple',
'mulitple' => true,
));**
$fieldset->addField('priority', 'text', array(
'label' => Mage::helper('lookbook')->__('Order of Display'),
'name' => 'priority[]',
));
$fieldset->addField('hiddenData', 'hidden', array(
'class' => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK) . '_' . Mage::registry('book_data')->getId(),
));
$statusArray = Mage::getSingleton('lookbook/status')->getOptionArray();
$fieldset->addField('publish', 'select', array(
'label' => Mage::helper('lookbook')->__('Status'),
'name' => 'publish[]',
'values' => $statusArray,
));
if (Mage::getSingleton('adminhtml/session')->getBookData()) {
$form->setValues(Mage::getSingleton('adminhtml/session')->getBookData());
Mage::getSingleton('adminhtml/session')->setBookData(null);
} elseif (Mage::registry('book_data')) {
$form->setValues(Mage::registry('book_data')->getData());
}
return parent::_prepareForm();
}
Take a look in Mage_Adminhtml_controllers_Catalog
You'll find references to the media_image attribute
You can follow the examples in adminhtml for grid's that allow multiple image uploading for the front end. On the backend side you either need your own resource models, or a backend source model declared for the attribute which can follow the backend and frontend models of the catalog images... in those classes you'll find examples of how the backend model deals with saving the images.