I am trying to upload a file from frontend. as bellow,
.phtml file
<label for="sb_link">Image</label>
<input type="file" id="bs_image" name="bs_image" required="true"/>
and in my controller I am doing
if (isset($_FILES['bs_image']['name']) && $_FILES['bs_image']['name'] != '') {
$path = Mage::getBaseDir() . '/test';
if (!file_exists($path)) {
mkdir($path, 777, true);
} try {
$fname = $_FILES['bs_image']['name'];
// $fname = $this->getRequest()->getParam('bs_image');
$uploader = new Varien_File_Uploader('bs_image');
$uploader->setAllowedExtensions(array('png', 'gif', 'jpeg', 'docx'));
$uploader->setAllowCreateFolders(true);
$uploader->setAllowRenameFiles(false);
$uploader->setFilesDispersion(false);
$uploader->save($path, $fname);
} catch (Exception $e) {
echo 'Error Message: ' . $e->getMessage();
}
}
folder is present, and getting no error/exception
, but file is not in folder. or there is an other way to do it. I was following Owais Kiani's
post
enctype="multipart/form-data"
print_r($_FILES);
what is output of this?