Yii框架CMultifileupload不能使用enctype

时间:2017-01-24 13:02:16

标签: php yii

我使用CMultifileupload上传多个文件,但不会发布'enctype' => 'multipart/form-data'

的文件

Controller.php这样

 public function actionProject_files($pid) {


           $model = new ProjectAttachment;

            if(isset($_POST['ProjectAttachment']) && !empty($_POST['ProjectAttachment'])){

                echo "<pre>";print_r($_POST['ProjectAttachment']);die;
           }
           $this->render('upload',array('model'=>$model));exit;


        }

upload.php的

<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'upload-form',
    'enableAjaxValidation'=>false,
    'htmlOptions' => array(
       'enctype' => 'multipart/form-data',

    ),
)); ?>


<?php  $this->widget('CMultiFileUpload',
  array(
       'model'=>$model,
       'attribute' => 'Document',
       'accept'=>'jpg|gif|png|doc|docx|pdf',
       'denied'=>'Only doc,docx,pdf and txt are allowed', 
       'max'=>4,
       'remove'=>'[x]',
       'duplicate'=>'Already Selected',

       )
        );?>
<button type="submit" class="btn btn-primary">Submit</button>
  <?php $this->endWidget(); ?>

提交$_POST['ProjectAttachment']

如果我使用$_FILES,则代码可以

工作行动

public function actionProject_files($pid) {

       $pmodel =  $this->loadModel($pid);    
       $model = new ProjectAttachment;

        if(isset($_FILES) && !empty($_FILES)){
           echo "<pre>";print_r($_POST);
            echo "<pre>";print_r($_FILES['ProjectAttachment']);die;
       }
       $this->render('my',array('pmodel' => $pmodel,'model'=>$model));exit;

       /* $usersModel = new ProjectMembers("searchByProject($id)");

        $usersModel->unsetAttributes();

    }

但为什么$_POST['ProjectAttachment']没有张贴请帮帮我

0 个答案:

没有答案