Magento image upload form field

前端 未结 1 990
故里飘歌
故里飘歌 2021-02-07 20:13

I followed this link to make image upload work within my Magento module, but the greatest thing all that code does is passing selected file name via POST: $_FILES a

相关标签:
1条回答
  • 2021-02-07 21:02

    The trick was to change the default form creation code

    $form = new Varien_Data_Form(array(
        'id' => 'edit_form',
        'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
        'method' => 'post',
    ));
    

    to

    $form = new Varien_Data_Form(array(
        'id' => 'edit_form',
        'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
        'method' => 'post',
        'enctype' => 'multipart/form-data'
    ));
    

    Not within the code i've provided, but within the caller for that partial (..._Adminhtml_News_Edit_Form instead of ..._Adminhtml_News_Edit_Tab_Form).

    0 讨论(0)
提交回复
热议问题