<?php if(isset($_FILES['myfilename']['name']) && $_FILES['myfilename']['name'] != '') { try { $path = Mage::getBaseDir('media') . DS . 'csvfile' . DS; //desitnation directory $fname = $_FILES['myfilename']['name']; //file name $filpath = $path.$fname; $uploader = new Varien_File_Uploader('myfilename'); //load class $uploader->setAllowedExtensions(array('xls','xlsx','csv')); //Allowed extension for file $uploader->setAllowCreateFolders(true); //for creating the directory if not exists $uploader->setAllowRenameFiles(false); //if true, uploaded file's name will be changed, if file with the same name already exists directory. $uploader->setFilesDispersion(false); $uploader->save($path,$fname); //save the file on the specified path } catch (Exception $e) { echo 'Error Message: '.$e->getMessage(); } } ?>
how to upload any file in magento
Step 1 :- cretae html form for upload file
Step 2 :- Write Script for upload file
Labels:
Magento
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment