view uploaded file in the form before create

hello , am new to Yii…

i am uploading file in my user form what i want is , my uploaded file should be view on the form beside that field only before creation of user… that field is not compulsory in my validation…

and one more thing i need to keep its size in kb only…

to validate the file size:

    public function rules() {

        return array(

            array('fileName', 'file', 'maxSize' => 1024 * 1024 * 3), //3mb



to save your file with the model:

	    $postedData = $_POST['Class'];


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

            $model->nm_fileName = $model->fileName->getName();

            $path = 'files/' . $model->nm_fileName;

            if ($model->save() && $model->fileName->saveAs($path)) {



thank you…

what should i do to view my uploaded file onclick of ‘view’ text or button before creation of record…

I think you need to follow two steps: one for the upload, another to save the model.

sorry but i didn’t understand what you want to say??

Sorry, maybe i did not understand what you need :( . Do you want to show a file (by example, like an image) to user, before you save the model?