本文整理汇总了PHP中Varien_File_Uploader::getUploadedFileName方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_File_Uploader::getUploadedFileName方法的具体用法?PHP Varien_File_Uploader::getUploadedFileName怎么用?PHP Varien_File_Uploader::getUploadedFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_File_Uploader
的用法示例。
在下文中一共展示了Varien_File_Uploader::getUploadedFileName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importAction
/**
* upload the file and run the import script on it
* if a file was already uploaded and the name
* of the file is sent in the post request then run the import on this file
*/
public function importAction()
{
set_time_limit(0);
$baseFileName = '';
$newUpdateFilename = '';
try {
//process the upload logic for the csv file
if (isset($_FILES['csv']['name']) && $_FILES['csv']['name'] != '') {
if (isset($_FILES['csv']['error']) && !empty($_FILES['csv']['error'])) {
$message = $this->getUploadCodeMessage($_FILES['csv']['error']);
throw new Exception($message, $_FILES['csv']['error']);
}
$uploader = new Varien_File_Uploader('csv');
$uploader->setAllowedExtensions(array('csv'));
$uploader->setAllowRenameFiles(true);
$uploader->setFilesDispersion(false);
$path = Mage::helper('zitec_dpd/postcode_search')->getPathToDatabaseUpgradeFiles();
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
$uploader->save($path, $_FILES['csv']['name']);
$newUpdateFilename = $path . $uploader->getUploadedFileName();
$baseFileName = $uploader->getUploadedFileName();
}
// if the no uploads made then check if the path_to_csv field was filed
if (empty($newUpdateFilename)) {
$baseFileName = $this->getRequest()->getPost('path_to_csv');
if (empty($baseFileName)) {
throw new Exception(Mage::helper('core')->__('Nothing to do!! Please upload a file or select an uploaded file.'));
}
if (isset($baseFileName)) {
$path = Mage::helper('zitec_dpd/postcode_search')->getPathToDatabaseUpgradeFiles();
$updateFilename = $path . $baseFileName;
if (!is_file($updateFilename)) {
throw new Exception(Mage::helper('core')->__('File %s was not found in path media/dpd/postcode_updates', $baseFileName));
}
$newUpdateFilename = $updateFilename;
}
}
if (!is_file($newUpdateFilename)) {
throw new Exception(Mage::helper('core')->__('File %s was not found in path media/dpd/postcode_updates', $baseFileName));
}
} catch (Exception $e) {
Mage::getSingleton('core/session')->addError($e->getMessage());
$this->_redirect("zitec_dpd/adminhtml_postcode/updateForm");
return;
}
// with the filename found, we need to run the database update script
// by calling the updateDatabase function of the postcode library
try {
Mage::helper('zitec_dpd/postcode_search')->updateDatabase($newUpdateFilename);
Mage::getSingleton('core/session')->addSuccess(Mage::helper('core')->__('Last updates found on file %s, were installed successfully.', $baseFileName));
} catch (Exception $e) {
Mage::getSingleton('core/session')->addError($e->getMessage());
}
$this->_redirect("zitec_dpd/adminhtml_postcode/updateForm");
}
示例2: postAction
public function postAction()
{
if (!empty($_FILES)) {
$type = 'file';
if (isset($_FILES[$type]['name']) && $_FILES[$type]['name'] != '') {
try {
$uploadsDir = Mage::getBaseDir('upload');
$uploader = new Varien_File_Uploader($type);
$uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
$uploader->setAllowRenameFiles(true);
$uploader->setFilesDispersion(true);
$path = Mage::getBaseDir('media') . DS . 'upload';
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
$uploader->save($path, $_FILES[$type]['name']);
$filename = $uploader->getUploadedFileName();
$md5 = md5($filename);
$owner = Mage::getSingleton('customer/session')->getCustomerId() ? Mage::getSingleton('customer/session')->getCustomerId() : Mage::getSingleton('customer/session')->getSessionId();
Mage::getModel('xxx_catalog/upload')->setMd5($md5)->setFilename($filename)->setOwner($owner)->save();
$varienImage = new Varien_Image($uploadsDir . $filename);
$width = $varienImage->getOriginalWidth();
$height = $varienImage->getOriginalHeight();
$data = ['id' => $md5, 'width' => $width, 'height' => $height];
echo json_encode($data);
die;
} catch (Exception $e) {
Mage::log($e->getMessage(), null, $this->_logFile);
echo json_encode(['error' => $this->__($e->getMessage())]);
}
}
}
$this->getResponse()->setRedirect(Mage::getUrl('*/*/index'));
}
示例3: _beforeSave
/**
* Save uploaded file before saving config value
*
* @return Mage_Adminhtml_Model_System_Config_Backend_Image
*/
protected function _beforeSave()
{
$value = $this->getValue();
if (is_array($value) && !empty($value['delete'])) {
$this->setValue('');
}
if ($_FILES['groups']['tmp_name'][$this->getGroupId()]['fields'][$this->getField()]['value']) {
$uploadDir = $this->_getUploadDir();
try {
$file = array();
$file['tmp_name'] = $_FILES['groups']['tmp_name'][$this->getGroupId()]['fields'][$this->getField()]['value'];
$file['name'] = $_FILES['groups']['name'][$this->getGroupId()]['fields'][$this->getField()]['value'];
$uploader = new Varien_File_Uploader($file);
$uploader->setAllowedExtensions($this->_getAllowedExtensions());
$uploader->setAllowRenameFiles(true);
$uploader->save($uploadDir);
} catch (Exception $e) {
Mage::throwException($e->getMessage());
return $this;
}
if ($filename = $uploader->getUploadedFileName()) {
if ($this->_addWhetherScopeInfo()) {
$filename = $this->_prependScopeInfo($filename);
}
$this->setValue($filename);
}
}
return $this;
}
示例4: handleUpload
/**
* Process uploaded file
* setup filenames to the configuration
*
* @param string $field
* @param mixed &$target
* @retun string
*/
public function handleUpload($field, &$target)
{
$uploadedFilename = '';
$uploadDir = $this->getOriginalSizeUploadDir();
$this->_forcedConvertPng($field);
try {
$uploader = new Varien_File_Uploader($field);
$uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
$uploader->setAllowRenameFiles(true);
$uploader->save($uploadDir);
$uploadedFilename = $uploader->getUploadedFileName();
$uploadedFilename = $this->_getResizedFilename($field, $uploadedFilename, true);
} catch (Exception $e) {
/**
* Hard coded exception catch
*/
if ($e->getMessage() == 'Disallowed file type.') {
$filename = $_FILES[$field]['name'];
Mage::throwException(Mage::helper('xmlconnect')->__('Error while uploading file "%s". Disallowed file type. Only "jpg", "jpeg", "gif", "png" are allowed.', $filename));
} else {
Mage::logException($e);
}
}
return $uploadedFilename;
}
示例5: load
public function load()
{
if (!$_FILES) {
?>
<form method="POST" enctype="multipart/form-data">
File to upload: <input type="file" name="io_file"/> <input type="submit" value="Upload"/>
</form>
<?php
exit;
}
if (!empty($_FILES['io_file']['tmp_name'])) {
//$this->setData(file_get_contents($_FILES['io_file']['tmp_name']));
$uploader = new Varien_File_Uploader('io_file');
$uploader->setAllowedExtensions(array('csv', 'xml'));
$path = Mage::app()->getConfig()->getTempVarDir() . '/import/';
$uploader->save($path);
if ($uploadFile = $uploader->getUploadedFileName()) {
$fp = fopen($uploadFile, 'rb');
while ($row = fgetcsv($fp)) {
}
fclose($fp);
}
}
return $this;
}
示例6: loadFile
public function loadFile()
{
if (!$_FILES) {
?>
<form method="POST" enctype="multipart/form-data">
File to upload: <input type="file" name="io_file"/> <input type="submit" value="Upload"/>
</form>
<?php
exit;
}
if (!empty($_FILES['io_file']['tmp_name'])) {
//$this->setData(file_get_contents($_FILES['io_file']['tmp_name']));
$uploader = new Varien_File_Uploader('io_file');
$uploader->setAllowedExtensions(array('csv', 'xml'));
$path = Mage::app()->getConfig()->getTempVarDir() . '/import/';
$uploader->save($path);
if ($uploadFile = $uploader->getUploadedFileName()) {
$session = Mage::getModel('dataflow/session');
$session->setCreatedDate(date('Y-m-d H:i:s'));
$session->setDirection('import');
$session->setUserId(Mage::getSingleton('admin/session')->getUser()->getId());
$session->save();
$sessionId = $session->getId();
$newFilename = 'import_' . $sessionId . '_' . $uploadFile;
rename($path . $uploadFile, $path . $newFilename);
$session->setFile($newFilename);
$session->save();
$this->setData(file_get_contents($path . $newFilename));
Mage::register('current_dataflow_session_id', $sessionId);
}
}
return $this;
}
示例7: afterSave
/**
* Save uploaded file and set its name to entity
*
* @param Goodahead_Etm_Model_Entity $object
* @return void
*/
public function afterSave($object)
{
parent::afterSave($object);
$value = $object->getData($this->getAttribute()->getName());
if (is_array($value) && !empty($value['delete'])) {
$object->setData($this->getAttribute()->getName(), '');
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
return $this;
}
$path = Mage::getBaseDir('media') . DS . 'goodahead' . DS . 'etm' . DS . 'images' . DS . $object->getEntityTypeInstance()->getEntityTypeCode() . DS . $this->getAttribute()->getAttributeCode() . DS;
try {
$uploader = new Varien_File_Uploader($this->getAttribute()->getName());
$uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
$uploader->setAllowRenameFiles(true);
$uploader->setAllowCreateFolders(true);
$uploader->setFilesDispersion(true);
$uploader->save($path);
$object->setData($this->getAttribute()->getName(), $uploader->getUploadedFileName());
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
} catch (Exception $e) {
if ($e->getCode() != Varien_File_Uploader::TMP_NAME_EMPTY) {
Mage::logException($e);
}
/** @TODO ??? */
return $this;
}
return $this;
}
示例8: importDataAction
public function importDataAction()
{
try {
if ($this->getRequest()->getPost()) {
if (isset($_FILES['import_file']['name']) && $_FILES['import_file']['name'] != '') {
$uploaderFile = new Varien_File_Uploader('import_file');
$uploaderFile->setAllowedExtensions(array('csv'));
$uploaderFile->setAllowRenameFiles(true);
$uploaderFile->setFilesDispersion(false);
$uploaderFilePath = Mage::getBaseDir('cache') . DS . 'mgs' . DS . 'brand' . DS . 'import' . DS . 'csv' . DS;
$uploaderFile->save($uploaderFilePath, $_FILES['import_file']['name']);
$filePath = $uploaderFilePath . $uploaderFile->getUploadedFileName();
$csv = new Varien_File_Csv();
$brands = $csv->getData($filePath);
$i = 0;
foreach ($brands as $brand) {
if ($i > 0) {
Mage::helper('brand')->import($brand);
}
$i++;
}
$urlRewriteCollection = Mage::getModel('core/url_rewrite')->getCollection()->addFieldToFilter('id_path', 'brand/index/');
foreach ($urlRewriteCollection as $url) {
$url->delete();
}
$urlRewrite = Mage::getModel('core/url_rewrite')->loadByIdPath('brand/index')->setIdPath('brand/index');
if (Mage::helper('brand')->urlKey() != '') {
$urlRewrite->setRequestPath(Mage::helper('brand')->urlKey());
} else {
$urlRewrite->setRequestPath('brand');
}
$urlRewrite->setTargetPath('brand/index/index');
$urlRewrite->setIsSystem(1);
$urlRewrite->save();
$collection = Mage::getModel('brand/brand')->getCollection();
foreach ($collection as $brand) {
$urlRewriteCollection = Mage::getModel('core/url_rewrite')->getCollection()->addFieldToFilter('id_path', 'brand/view/' . $brand->getId());
foreach ($urlRewriteCollection as $url) {
$url->delete();
}
$urlRewrite = Mage::getModel('core/url_rewrite')->loadByIdPath('brand/view/' . $brand->getId())->setIdPath('brand/view/' . $brand->getId());
if (Mage::helper('brand')->urlKey() != '') {
$urlRewrite->setRequestPath(Mage::helper('brand')->urlKey() . '/' . $brand->getUrlKey());
} else {
$urlRewrite->setRequestPath('brand/' . $brand->getUrlKey());
}
$urlRewrite->setTargetPath('brand/index/view/id/' . $brand->getId());
$urlRewrite->setIsSystem(1);
$urlRewrite->save();
}
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('brand')->__('All brands were successfully imported.'));
$this->_redirect('*/*/index');
}
}
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
$this->_redirect('*/*/import');
}
}
示例9: saveAction
public function saveAction()
{
$this->checkFilter();
if ($data = $this->getRequest()->getPost()) {
if (isset($_FILES['imagename']['name']) && $_FILES['imagename']['name'] != '') {
try {
/* Starting upload */
$uploader = new Varien_File_Uploader('imagename');
// Any extention would work
$uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
$uploader->setAllowRenameFiles(false);
// Set the file upload mode
// false -> get the file directly in the specified folder
// true -> get the file in the product like folders
// (file.jpg will go in something like /media/f/i/file.jpg)
$uploader->setFilesDispersion(false);
$NewName = time() . $_FILES['imagename']['name'];
// We set media as the upload dir
$path = Mage::getBaseDir('media') . DS . 'images' . DS . 'slider';
// $uploader->save($path, $_FILES['imagename']['name'] );
$uploader->save($path, $NewName);
$data['imagename'] = $uploader->getUploadedFileName();
} catch (Exception $e) {
}
}
// end if valid file
$model = Mage::getModel('slider/imageslider');
$model->setData($data)->setId($this->getRequest()->getParam('id'));
try {
if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
$model->setCreatedTime(now())->setUpdateTime(now());
} else {
$model->setUpdateTime(now());
}
$model->save();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('slider')->__('Item was successfully saved'));
Mage::getSingleton('adminhtml/session')->setFormData(false);
if ($this->getRequest()->getParam('back')) {
// die('do back action');
// $this->_redirect('*/*/edit', array('id' => $model->getId()));
$this->_redirect('*/*/edit', array('id' => $model->getId()));
return;
}
$this->_redirect($this->_RedirectLink);
// $this->_redirect('*/*/');
return;
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::getSingleton('adminhtml/session')->setFormData($data);
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
return;
}
}
// end if get post ok
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('slider')->__('Unable to find item to save'));
$this->_redirect($this->_RedirectLink);
// $this->_redirect('*/*/');
}
示例10: _beforeSave
/**
* Save uploaded file before saving config value
*
* @return Mage_Adminhtml_Model_System_Config_Backend_Image
*/
protected function _beforeSave()
{
$value = $this->getValue();
if (is_array($value) && !empty($value['delete'])) {
$this->setValue('');
}
if ($_FILES['groups']['tmp_name'][$this->getGroupId()]['fields'][$this->getField()]['value']) {
$fieldConfig = $this->getFieldConfig();
/* @var $fieldConfig Varien_Simplexml_Element */
if (empty($fieldConfig->upload_dir)) {
Mage::throwException(Mage::helper('catalog')->__('Base directory to upload image file is not specified'));
}
$uploadDir = (string) $fieldConfig->upload_dir;
$el = $fieldConfig->descend('upload_dir');
/**
* Add scope info
*/
if (!empty($el['scope_info'])) {
$uploadDir = $this->_appendScopeInfo($uploadDir);
}
/**
* Take root from config
*/
if (!empty($el['config'])) {
$uploadRoot = (string) Mage::getConfig()->getNode((string) $el['config'], $this->getScope(), $this->getScopeId());
$uploadRoot = Mage::getConfig()->substDistroServerVars($uploadRoot);
$uploadDir = $uploadRoot . '/' . $uploadDir;
}
try {
$file = array();
$file['tmp_name'] = $_FILES['groups']['tmp_name'][$this->getGroupId()]['fields'][$this->getField()]['value'];
$file['name'] = $_FILES['groups']['name'][$this->getGroupId()]['fields'][$this->getField()]['value'];
$uploader = new Varien_File_Uploader($file);
$uploader->setAllowedExtensions($this->_getAllowedExtensions());
$uploader->setAllowRenameFiles(true);
$uploader->save($uploadDir);
} catch (Exception $e) {
Mage::throwException($e->getMessage());
return $this;
}
if ($filename = $uploader->getUploadedFileName()) {
/**
* Add scope info
*/
if (!empty($el['scope_info'])) {
$filename = $this->_prependScopeInfo($filename);
}
$this->setValue($filename);
}
}
return $this;
}
示例11: saveAction
/**
* Save action
*/
public function saveAction()
{
if (!($data = $this->getRequest()->getPost('testimonials'))) {
$this->_redirect('*/*/');
return;
}
$model = Mage::getModel('tm_testimonials/data');
if ($id = $this->getRequest()->getParam('testimonial_id')) {
$model->load($id);
}
try {
$mediaPath = Mage::getBaseDir('media') . DS . TM_Testimonials_Model_Data::IMAGE_PATH;
if (isset($_FILES['image']) && $_FILES['image']['error'] == 0) {
try {
$uploader = new Varien_File_Uploader('image');
$uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png', 'bmp'));
$uploader->setAllowRenameFiles(true);
$uploader->setFilesDispersion(true);
$res = $uploader->save($mediaPath);
$data['image'] = $uploader->getUploadedFileName();
} catch (Exception $e) {
$this->_getSession()->addError($e->getMessage());
}
}
if (isset($data['image']) && is_array($data['image'])) {
if (!empty($data['image']['delete'])) {
@unlink($mediaPath . $data['image']['value']);
$data['image'] = null;
} else {
$data['image'] = $data['image']['value'];
}
}
$model->addData($data);
$date = Mage::app()->getLocale()->date($data['date'], Zend_Date::DATE_SHORT, null, false);
$model->setDate($date->toString('YYYY-MM-dd HH:mm:ss'));
$model->save();
// clear testimonials list block cache after new item was added
Mage::app()->cleanCache(array('tm_testimonials_list'));
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('testimonials')->__('Testimonial has been saved.'));
Mage::getSingleton('adminhtml/session')->setFormData(false);
if ($this->getRequest()->getParam('back')) {
$this->_redirect('*/*/edit', array('testimonial_id' => $model->getId(), '_current' => true));
return;
}
$this->_redirect('*/*/');
return;
} catch (Exception $e) {
$this->_getSession()->addError($e->getMessage());
}
$this->_getSession()->setFormData($data);
$this->_redirect('*/*/edit', array('testimonial_id' => $this->getRequest()->getParam('testimonial_id'), '_current' => true));
}
示例12: afterSave
public function afterSave($object)
{
$value = $object->getData($this->getAttribute()->getName());
if (is_array($value) && !empty($value['delete'])) {
$object->setData($this->getAttribute()->getName(), '');
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
return;
}
try {
$uploader = new Varien_File_Uploader($this->getAttribute()->getName());
$uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
$uploader->setAllowRenameFiles(true);
$uploader->setFilesDispersion(true);
} catch (Exception $e) {
return;
}
$uploader->save(Mage::getStoreConfig('system/filesystem/media') . '/catalog/category');
if ($uploader->getUploadedFileName()) {
$object->setData($this->getAttribute()->getName(), $uploader->getUploadedFileName());
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
}
}
示例13: saveAvatarFile
public function saveAvatarFile()
{
$uploadedFile = null;
if ($fileData = $this->getAvatarFileData()) {
$uploader = new Varien_File_Uploader($this->getAvatarFileData());
$uploader->setFilesDispersion(true);
$uploader->setFilenamesCaseSensitivity(false);
$uploader->setAllowRenameFiles(true);
$uploader->setAllowedExtensions($this->_supportedExtensions);
$uploader->save($this->getAvatarBasePath(), $fileData['name']);
$uploadedFile = $uploader->getUploadedFileName();
}
return $uploadedFile;
}
示例14: saveAction
public function saveAction()
{
if ($this->getRequest()->getPost()) {
try {
$postData = $this->getRequest()->getPost();
$imageModel = Mage::getModel('aitcg/mask');
if (isset($_FILES['filename']['name']) and file_exists($_FILES['filename']['tmp_name'])) {
$uploader = new Varien_File_Uploader('filename');
$uploader->setAllowedExtensions(array('png'));
$uploader->setAllowRenameFiles(true);
$uploader->setFilesDispersion(false);
$path = $imageModel->getImagesPath();
$uploader->save($path, preg_replace('/[^A-Za-z\\d\\.]/', '_', $_FILES['filename']['name']));
$postData['filename'] = $uploader->getUploadedFileName();
}
$imageModel->load($this->getRequest()->getParam('imgid'))->setName($postData['name'])->setResize($postData['resize'])->setCategoryId($this->getRequest()->getParam('id'));
if (isset($postData['filename'])) {
if ($imageModel->getFilename()) {
$fullPath = $imageModel->getImagesPath() . $imageModel->getFilename();
@unlink($fullPath);
$fullPath = $imageModel->getImagesPath() . 'preview' . DS . $imageModel->getFilename();
@unlink($fullPath);
}
$imageModel->setFilename($postData['filename']);
$thumb = new Varien_Image($imageModel->getImagesPath() . $imageModel->getFilename());
$thumb->open();
$thumb->keepAspectRatio(true);
$thumb->keepFrame(true);
$thumb->backgroundColor(array(255, 255, 255));
#$thumb->keepTransparency(true);
$thumb->resize(135);
$thumb->save($imageModel->getImagesPath() . 'preview' . DS . $imageModel->getFilename());
$imageModel->createInvertMask();
}
$imageModel->save();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully saved'));
Mage::getSingleton('adminhtml/session')->setImageData(false);
$this->_redirect('*/*/', array('id' => $this->getRequest()->getParam('id')));
return;
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::getSingleton('adminhtml/session')->setImageData($this->getRequest()->getPost());
$this->_redirect('*/*/edit', array('imgid' => $this->getRequest()->getParam('imgid'), 'id' => $this->getRequest()->getParam('id')));
return;
}
}
$this->_redirect('*/*/', array('id' => $this->getRequest()->getParam('id')));
}
示例15: applyPostAction
/**
* action after form submition
*/
public function applyPostAction()
{
if ($data = $this->getRequest()->getPost()) {
$session = $this->_getSession();
$model = Mage::getModel('zeon_jobs/application');
try {
if (!empty($data)) {
$model->addData($data);
$session->setFormData($data);
}
if (isset($_FILES['upload_resume']['name']) && $_FILES['upload_resume']['name'] != '') {
$uploader = new Varien_File_Uploader('upload_resume');
$uploader->setAllowedExtensions(explode(',', Mage::helper('zeon_jobs')->getAllowedFileExtensions()));
$uploader->setAllowRenameFiles(true);
$uploader->setFilesDispersion(false);
$path = Mage::getBaseDir('media') . DS . 'resumes' . DS;
$_FILES['upload_resume']['name'] = str_replace(' ', '-', $_FILES['upload_resume']['name']);
$uploader->save($path, $_FILES['upload_resume']['name']);
$model->setUploadResume($uploader->getUploadedFileName());
}
$model->save();
$session->addSuccess(Mage::helper('zeon_jobs')->__('Your application has been submitted. Thank you for contacting us.'));
$translate = Mage::getSingleton('core/translate');
$translate->setTranslateInline(false);
/*To send email*/
$dataObject = new Varien_Object();
$dataObject->setData($data);
//Send Email Notification to Admin & User
if (!$model->sendNotificationEmail($dataObject)) {
throw new Exception('Email notification has not been sent.');
}
$translate->setTranslateInline(true);
// Redirect to a success page, at the moment it goes back to the job list.
$this->_redirect('careers');
return;
} catch (Exception $e) {
$session->addError($e->getMessage());
$session->getFormData($data);
$this->_redirect('careers');
return;
}
}
}