2
votes

I need to upload my customized excel file in magento admin panel. This excel file data's will be filter shipping details in checkout page. So i am trying to create new module in magento admin panel.

Right now i can't create excel file upload option in admin panel. So can any one know about file upload concept in admin panel? or any other default functionality having for file upload in magento?

Can any one suggest me right method to export excel file in admin? Thanks

1
This question is a little broad for the StackOverflow format. Generally you should post code of something you have tried, explain the expected result, and describe the error you are getting.MDrollette
Hi I have tried to show file upload option (<input type="file" /> ) on my customized module in admin panel. But i can't to show file upload option in mymodule. Right now i am new to magento. So can you explain me right method for file upload options?Maniprakash Chinnasamy
@Prakash it's not so easy to explain. You should go to read some tutorial about CRUD module creation. Try to check alanstorm.com websiteSergii Stotskyi

1 Answers

2
votes

To upload file you can use Varien_File_Uploader class:

try {
   $uploader = new Varien_File_Uploader("%NAME_OF_THE_INPUT_FILE_FIELD_IN_FORM%");
   $uploader->setAllowedExtensions(array('xls', 'xlsx'));
   $uploader->setAllowCreateFolders(true);

   $isValidMime = $uploader->checkMimeType(array('%excel_mime_type%'));
   if ($isValidMime) {
       $uploader->save($destinationDir, $newFilename);
   }
} catch (Exception e) {
  echo $e->getMessage();
}

The second parameter for save method is optional