2013-10-05 118 views
-1

你好我在做警予多文件上傳...多文件上傳

我有安裝形式使用多個文件上傳這樣的...

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

,但如果只有我使用多文件上傳控件循環,它不會裏面......

它的正常工作與單文件上傳(如下圖所示),並上傳也...但它顯示的問題在多文件上傳..

<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> 

我不會做什麼用我的代碼去錯了......我指的這個帖子

回答

0

由於您使用的是attribute插件選項,則不應使用name

$this->widget('CMultiFileUpload', array(
    '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 
)); 

PS:下一次,你應該嘗試一個簡單的var_dump($_POST);