嗨,我正在 yii 中进行多个文件上传...
我有设置表单来使用这样的多个文件上传......
myfrom.php
<?php
$form=$this->beginWidget('CActiveForm', array(
'id'=>'topic-form',
'enableAjaxValidation'=>false,
'htmlOptions' => array('enctype' => 'multipart/form-data'), // ADD THIS
));
?>
<div class="row">
<?php
$this->widget('CMultiFileUpload', array(
'name' => 'imagepath',
'model'=> $model,
'attribute'=>'imagepath',
'accept' => 'jpeg|jpg|gif|png', // useful for verifying files
'duplicate' => 'Duplicate file!', // useful, i think
'denied' => 'Invalid file type', // useful, i think
));
?>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
我的控制器方法看起来像......
public function actionMultipleupload()
{
$model= new Uploadimage();
if(isset($_POST['Uploadimage']))
{
var_dump("inside if");
// $images = CUploadedFile::getInstancesByName('images');
}
var_dump("out side if");
$this->render('multipleupload',array('model'=>$model));
}
但只有当我使用多文件上传小部件时,它才不会进入 if 循环......
它适用于单个文件上传(如下所示)并且也可以上传......但它在多个文件上传中显示问题..
<div class="row">
<?php echo $form->labelEx($model,'imagepath'); ?>
<?php echo CHtml::activeFileField($model,'imagepath',array('size'=>60,'maxlength'=>500)); ?>
<?php echo $form->error($model,'imagepath'); ?>
</div>
我不知道我的代码出了什么问题......我指的是这篇文章