prestashop 1.6将(上传文件)字段添加到类别

时间:2015-07-10 10:25:48

标签: file-upload field prestashop add-in

嗨,我在将上传文件字段添加到类别(管理员)时遇到问题     这就是我所做的:
    copy /controllers/admin/AdminCategoriesController.php >> /手柄/控制器/管理/
    我删除了除 renderForm()函数之外的所有内容,所以我的代码如下:
    

    class AdminCategoriesController extends AdminCategoriesControllerCore
    {
        public function renderForm()
        {
            everything from original file
            ...
            return AdminController::renderForm();
        }
    }
    
    所以,我的观点(问题)是:
    我应该在
$this->fields_form = array(...
'input' => array(
HERE
中加入什么     我试过这个:
    
    array(
      'type' => 'file',
      'label' => $this->l('File'),
      'name' => 'new_file',
      'file' => isset($link) ? $link : null,
      'size' => isset($size) ? $size : null,
      'delete_url' => self::$currentIndex.'&'.$this->identifier.'='.$this->_category->id.'&token='.$this->token.'&deleteFile=1',
      'hint' => $this->l('Upload a file to category from your computer.'),
    ),
    
    在此之前我写(在AdminAttachmentsController.php中就像这样):
    
    if (($obj = $this->loadObject(true)) && Validate::isLoadedObject($obj))
      {
        $link = $this->context->link->getPageLink('category', true, NULL, 'id_category='.$obj->id);

if (file_exists(_PS_CAT_IMG_DIR_.$obj->file)) $size = round(filesize(_PS_CAT_IMG_DIR_.$obj->file) / 1024); } But it won't copy the file on server ... Thank for any answers.

0 个答案:

没有答案