CActiveForm & File field


I have some troubles to get the file field working in a CActive form. Here is the script :

model :

public function rules() {

        return array(

            array('firstname, lastname, mail, notification, userid', 'required', 'message'=>Yii::t('common', 'form.field.required'), 'on'=>'register'),

            array('userid, firstname, lastname, mail, notification', 'safe', 'on'=>'search'),

            array('mail', 'email', 'message'=>Yii::t('common', '')),

            array('file', 'file', 'types'=>'jpg, gif, png', 'allowEmpty'=>true, 'message'=>Yii::t('common', '')),

            array('avatar, notification', 'default', 'setOnEmpty' => true, 'value' => null),

            array('userid, firstname, lastname, mail', 'length', 'max'=>128),

            array('notification', 'numerical', 'integerOnly'=>true),



Controller :

    public function actionRegister()


        //Create the models

        $user_model = new User('register');

        $profile_model = new Profile('register');

        if(isset($_POST['User']) && $_POST['Profile'])


            //Massive assigments from $_POST





            //Check if the models are valided

            if($user_model->validate() && $profile_model->validate())


                //Then save






        //Render the wiew with the models as params

        $this->render('register', array(





and view :


$user_form = $this->beginWidget('CActiveForm',array(


    'clientOptions' => array(




        'enctype' => 'multipart/form-data',




<div class="control-group">

    <?php echo $user_form->textField($user_model,'username', array('placeholder'=>$user_model->getAttributeLabel('username'))); ?>

    <?php $user_form->error($user_model,'username'); ?>


<div class="control-group">

    <?php echo $user_form->passwordField($user_model,'password', array('placeholder'=>$user_model->getAttributeLabel('password'))); ?>

    <?php $user_form->error($user_model,'password'); ?>


<div class="control-group">

    <?php echo $user_form->passwordField($user_model,'repeat_password', array('placeholder'=>$user_model->getAttributeLabel('repeat_password'))); ?>

    <?php $user_form->error($user_model,'repeat_password'); ?>


<div class="control-group">

    <?php echo $user_form->textField($profile_model,'firstname', array('placeholder'=>$profile_model->getAttributeLabel('firstname'))); ?>

    <?php $user_form->error($profile_model,'firstname'); ?>


<div class="control-group">

    <?php echo $user_form->textField($profile_model,'lastname', array('placeholder'=>$profile_model->getAttributeLabel('lastname'))); ?>

    <?php $user_form->error($profile_model,'lastname'); ?>


<div class="control-group">

    <?php echo $user_form->textField($profile_model,'mail', array('placeholder'=>$profile_model->getAttributeLabel('mail'))); ?>

    <?php $user_form->error($profile_model,'mail'); ?>


<div class="control-group">

    <label class="checkbox">

        <?php echo $user_form->checkBox($profile_model,'notification'); ?> <?php echo $profile_model->getAttributeLabel('notification'); ?>



<div class="control-group">

    <?php echo $user_form->fileField($profile_model,'file', array('class'=>'input-file')); ?>

    <?php echo $user_form->error($profile_model,'file'); ?>


<?php echo CHtml::submitButton(Yii::t('common', ''), array('class'=>'btn btn-primary')) ?>

<?php echo CHtml::link(Yii::t('common', 'common.back'), Yii::app()->getRequest()->urlReferrer, array('class'=>'btn btn-warning')) ?>

<?php $this->endWidget(); ?>

  • When I try to send an image, there is no problem.

  • When I try to send a txt file, there is no problem, the error message is displayed

  • When I try to send nothing, there is no problem

- When I try to send any video file, the browser is turning again and again but nothing happens.

In Chrome I have the following on submit :

The submit button doesn’t even try to reload the page. The upload is stuck at 0%. (i’m using wamp here)

Why the hell can I submit txt or images files but not video (like avi or wmv) ? :-[



Ok maybe cause of the file weight !

But is it normal for the browsers to make nothing in submit when the file is too big ? How can I prevent it ?