0
我在magento中創建了一個自定義管理模塊。該模塊具有向提交文件上傳的控制器提交帖子的表單。文件上傳不能在Magento中使用自定義管理模塊
我正在上提交表單以下錯誤:
a:5:{i:0;s:22:"File was not uploaded.";i:1;s:1030:"#0 C:\wamp\www\magento-PhpDevGuide-packt\app\code\local\Endosoft\Categoryupdate\controllers\Adminhtml\CategoryupdateController.php(11): Varien_File_Uploader->__construct('uploadcsv')
#1 C:\wamp\www\magento-PhpDevGuide-packt\app\code\core\Mage\Core\Controller\Varien\Action.php(418): Endosoft_Categoryupdate_Adminhtml_CategoryupdateController->formPostAction()
#2 C:\wamp\www\magento-PhpDevGuide-packt\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('formpost')
#3 C:\wamp\www\magento-PhpDevGuide-packt\app\code\core\Mage\Core\Controller\Varien\Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#4 C:\wamp\www\magento-PhpDevGuide-packt\app\code\core\Mage\Core\Model\App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#5 C:\wamp\www\magento-PhpDevGuide-packt\app\Mage.php(684): Mage_Core_Model_App->run(Array)
#6 C:\wamp\www\magento-PhpDevGuide-packt\index.php(87): Mage::run('', 'store')
#7 {main}";s:3:"url";s:78:"/index.php/admin/categoryupdate/formpost/key/d91e6825136ce2206d7c72bbd1b7af34/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:5:"admin";}
下面的形式:
<?php $url = Mage::helper("adminhtml")->getUrl('adminhtml/categoryupdate/formpost'); ?>
<h4>Upload Your CSV</h4>
<form action="<?php echo $url ?>" method="post" enctype="multipart/form-data">
<p><input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" /></p>
<p><input type="file" name="csvupload" /></p>
<p><input type="submit" name="submit" value="Submit" /></p>
</form>
這裏是控制器方法:
public function formPostAction() {
$uploader = new Varien_File_Uploader('uploadcsv');
$uploader->setAllowedExtensions(array('json'));
$uploader->setAllowRenameFiles(false);
$uploader->setFilesDispersion(false);
$path = Mage::getBaseDir('media');
$fileName = $_FILES['uploadcsv']['name'];
$uploader->save($path, $fileName);
$this->loadLayout();
$this->renderLayout();
}
我做不到了解文件未上傳的原因。
難道有人請澄清出了什麼問題嗎?
附加信息:
- 相反
認真的兄弟,整整一天因爲這個非常愚蠢的錯誤而浪費了,非常感謝,這讓我像任何事情一樣困擾着我! – brucekaushik