File Upload not working in Magento from custom admin module -
i want upload file try lot can't thing , did't error in log didn't gat type of file in folder. here form
class sample_bigcom_block_adminhtml_form_edit_file extends mage_adminhtml_block_system_config_form_field { protected function _getelementhtml(varien_data_form_element_abstract $element) { $url = mage::helper("adminhtml")->geturl('bigcom/ajax/process/'); //echo $url; $value=mage::getsingleton('core/session')->getformkey(); //$url1 = mage::helper("adminhtml")->geturl('seosetup/ajax/processtest/'); $html = '<form action="'.$url.'" method="post" enctype="multipart/form-data"> <p><input name="form_key" type="hidden" value="'.$value.'" /></p> <p><input type="file" name="csvupload" /></p> <p><input type="submit" name="submit" value="submit" /></p> </form>'; return $html; } }
here controller
class sample_bigcom_ajaxcontroller extends mage_adminhtml_controller_action { public function indexaction() { $this->loadlayout(); $this->renderlayout(); } public function processaction() { $uploader = new varien_file_uploader('csvupload'); // extention work $uploader->setallowedextensions(array('jpg', 'jpeg', 'gif', 'png')); $uploader->setallowrenamefiles(false); // set file upload mode // false -> file directly in specified folder // true -> file in product folders // (file.jpg go in /media/f/i/file.jpg) $uploader->setfilesdispersion(false); // set media upload dir $path = mage::getbasedir('media') . ds; //$path = 'http://localhost/magentobigcom/media/'; $uploader->save($path, $_files['csvupload']['name']); } }
could please clarify going wrong?
Comments
Post a Comment