Yii:使用CActiveForm获取表单文件的问题

My form:

<?php 
     $form=$this->beginWidget('CActiveForm', array(
    'id'=>'news-form',
    'htmlOptions'=>array('enctype'=>'multipart/form-data'),
));
?>

     <div class="form-group col-sm-12 col-md-6">
       <?php echo $form->labelEx($news,'state'); ?>
       <?php echo $form->dropDownList($news,'state', CHtml::listData($op,'Value','Type'),array('class' => 'form-control')) ?>
       <?php echo $form->error($news,'state'); ?>
      </div>

     <!-- HERE MY PROBLEM -->
     <input type="file" name="original" onchange="change(event)" id="original" />

     <?php echo CHtml::submitButton(Yii::t('app','CreateNewsLabel'), array('class' => 'btn btn-primary'), $news->isNewRecord ? 'Create' : 'Save'); ?>

When into my Controller I try to get file, that doesn't exists:

    if (isset($_FILE['original'])) {
        //..
    }

The if is never executed. I have tried a lot of possible solutions but doesn' work. I dont understand the reason because I'm using mulipart/form-data and should be exists...

Thanks you, regards.

It seems you have a typo. try to use

if (isset($_FILES['original'])) {
        //..
}

you can also try to do your validation like this via YII instead of doing the default PHP way.

$model->image=CUploadedFile::getInstance($model,'original');

In the view you can add this.

echo $form->labelEx($model, 'original');
echo $form->fileField($model, 'original');
echo $form->error($model, 'original');

to add validations to your file before uploading try this.

public function rules()
{
    return array(
        array('original', 'file', 'types'=>'jpg, gif, png', 'safe' => false),
    );
}