文件未在路径文件夹magento中上传

时间:2015-11-19 06:56:17

标签: magento magento-1.9 magento-1.9.1

我为职业表单页面创建了一个自定义模块。我添加了一个附加恢复字段。当我选择一个文件并单击提交按钮时,文件名将保存到数据库,但文件不会在media / career文件夹中上传。

请参阅以下代码了解控制器操作:

public function careersaveAction() {     

$data=$this->getRequest()->getParams(); 

  $fileName = '';



                        $fileName       = $_FILES['resume_path']['name'];                       
                        $fileExt        = strtolower(substr(strrchr($fileName, ".") ,1));                       
                        $fileNamewoe    = rtrim($fileName, $fileExt);
                        $fileName       = preg_replace('/\s+', '', $fileNamewoe) . time() . '.' . $fileExt; 
                        $uploader       = new Varien_File_Uploader('resume_path');
                        $uploader->setAllowedExtensions(array('doc', 'docx','pdf', 'jpg', 'png', 'zip')); //add more file types you want to allow

                        $uploader->setAllowRenameFiles(false);
                        $uploader->setFilesDispersion(false);
                        $path = Mage::getBaseDir('media') . DS . 'career';

                        if(!is_dir($path)){
                            mkdir($path, 0777, true);
                        }
                        $uploader->save($path . DS, $fileName );

      $career = Mage::getModel("career/career")->setData($data);
         if($career->Save()){
         Mage::getSingleton('core/session')->addSuccess("Thank you for get in touch with us. We will contact you soon.");
         $this->_redirect('career/index/');

         } else {
        Mage::getSingleton('core/session')->addError("Sorry, your informations are not submitted this time. Request you to try again.");
$this->_redirect('career/index/');

         }

    }
}

请参阅代码并告诉我解决方案。 谢谢!

0 个答案:

没有答案