$fileName = '';
			if(isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') {
				try {
					$fileName       = $_FILES['attachment']['name'];
					$fileExt        = strtolower(substr(strrchr($fileName, ".") ,1));
					$fileNamewoe    = rtrim($fileName, $fileExt);
					$fileName       = preg_replace('/\s+', '', $fileNamewoe) . time() . '.' . $fileExt;

					$uploader       = new Varien_File_Uploader('attachment');
					$uploader->setAllowedExtensions(array('doc', 'docx','pdf', 'jpg','jpeg', 'png', 'zip','gif','csv','txt','xlt','xls','xlsx')); 
					//add more file types you want to allow
					$uploader->setAllowRenameFiles(false);
					$uploader->setFilesDispersion(false);
					$path = Mage::getBaseDir('media') . WT . 'inquiry';
					if(!is_dir($path)){
						mkdir($path, 0777, true);
					}
					$uploader->save($path . WT, $fileName );
				} catch (Exception $e) {
					echo $e->getMessage();
				}
			}
Your Answer
Sign In
Enter email and password to comment or answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.