Uploading Multiple Image In Yii

I have been trying to upload multiple file i.e. image.

my model Student.php looks like

class Student extends CActiveRecord {

//    public $photo;

    function tableName(){

        return 'student';


    function rules(){

        return array(

            array('name,address,roll,photo,image ','required'),

            array('photo', 'file'),





my Controller looks like

public function actionSaveStudent(){

       // $model=new Student;

        $model=new Student();  // this is my model related to table










            $rnd = rand(0,9999);  // generate random number between 0-9999




            $fileName = "{$rnd}-{$uploadedFile}";  // random number + file name

            $model->photo = Yii::app()->basePath.'/student/'.$fileName;

            $model->image = Yii::app()->basePath.'/created_htdocs/'.$fileName;



            // $model->photo = $fileName;





                    echo "saved";



                    echo 'failure';





       // $this->render("newstudent");




and my view looks like

<form action="savestudent"  enctype="multipart/form-data" method="post">

   <label> Name: <input name="name" type="text" ></label> <br><br>

   <label> Roll: <input name="roll" type="text" ></label><br><br>

   <label>Address: <input name="address" type="text" ></label><br><br>


        <?php echo CHtml::activeFileField($model,'photo'); ?><br><br>Attachment 5384 not found.

    <?php echo CHtml::activeFileField($model,'image'); ?><br><br>

    <input type="submit" name="submit" id="submit" value="Save">


and i got error Property "Student.image" is not defined.

This line is causing that error:

<?php echo CHtml::activeFileField($model,'image'); ?>

This still won’t work while the $photo attribute of Student is commented out though.

I’ve deleted your duplicate thread. If you wish to include the files you attached again, you should update your first post here to add them.