文件上传在自定义管理模块的Magento中不起作用

时间:2015-08-03 06:57:38

标签: magento file-upload

我想上传文件我尝试很多不能做这件事也没有在日志中得到任何错误只是没有gat文件夹中的任何类型的文件。    这是表格

class Sample_Bigcom_Block_Adminhtml_Form_Edit_File extends Mage_Adminhtml_Block_System_Config_Form_Field
    {
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
        {

        $url =  Mage::helper("adminhtml")->getUrl('bigcom/ajax/process/');
        //echo $url;
        $value=Mage::getSingleton('core/session')->getFormKey();
        //$url1 =   Mage::helper("adminhtml")->getUrl('seosetup/ajax/processtest/');
                  $html = '<form action="'.$url.'" method="post" enctype="multipart/form-data">
        <p><input name="form_key" type="hidden" value="'.$value.'" /></p>
        <p><input type="file" name="csvupload" /></p>
        <p><input type="submit" name="submit" value="Submit" /></p>
    </form>';      
     return $html;
        }
    }  

这是控制器

class Sample_Bigcom_AjaxController extends Mage_Adminhtml_Controller_Action
         {

            public function indexAction() {
                $this->loadLayout();
                $this->renderLayout();
            }

            public function processAction() {
        $uploader = new Varien_File_Uploader('csvupload');

        // 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);

        // We set media as the upload dir
        $path = Mage::getBaseDir('media') . DS;
        //$path = 'http://localhost/magentobigcom/media/';
        $uploader->save($path, $_FILES['csvupload']['name']);

            }

        }

有人可以澄清出了什么问题吗?

0 个答案:

没有答案