Validating And Save An Uploaded Ajax Image In Yii Without Using $Model

I need to send an image to server via an ajax request and it gets through just fine

and in my controller I can just use $_FILES["image"] to do stuff to it.

but I need to validate the image before I save it.

and in Yii this can be achieved by doing something like this:



$model->image->saveAs(Yii::getPathOfAlias('webroot') . '/upload/user_thumb/' . $model->username.'.'.$model->photo->extensionName);


but the problem is I don’t have a $model , all I have is $_FILES[“image”], now what should I put instead of the $model???

is there any other way where I can validate and save files without creating a model and just by Using $_FILES["image"]?

thanks for this awesome community… :)

set the validation rule in your model

[font="Arial"] [/font]


  array('image_name', 'file', 'types' => 'jpg, jpeg, gif, png','on'=>'create','minSize'=>559631,'tooLarge'=>'The file was larger than 559631K. Please upload a smaller file.'),

  array('image_name', 'file', 'allowEmpty' => TRUE,'types' => 'jpg, jpeg, gif, png','on'=>'update'),

[font="Arial"] [/font]