Uploading Files in Magento


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. if (isset($_FILES['logo']['name']) && $_FILES['logo']['name'] != '') {
  2. try {
  3. $uploader = new Varien_File_Uploader('logo');
  4. $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
  5. $uploader->setAllowRenameFiles(false);
  6. $uploader->setFilesDispersion(false);
  7. $path = Mage::getBaseDir('media') . DS;
  8. // $path = Mage::getBaseDir('media') . DS . 'logo' . DS;
  9. $logoName = $_FILES['logo']['name'];
  10. $uploader->save($path, $logoName);
  11.  
  12. } catch (Exception $e) {
  13.  
  14. }
  15. }

URL: http://blog.chapagain.com.np/magento-how-to-upload-file/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.