upload image

Hi, I am quite new on Yii framework.

I had a form generated with CRUD, and I need to add a field to upload an image.

I did use this tutorial , but with no result,


The file field appears in the form, but when I submit the form with the image, it doesn’t save th image,

if I change the code in the controller, and I put just something like



just to see which are the post variable, the image field variable looks empty.

it print lsomwe thing like

name->neme submitted

surname->surname submitter


with the image field empty.

any idea what could be?

I’ve read some post about changing ajaxValidation form true to false,

but no luck

should ajaxValidation be true or false?

thank you


Try print_r($_FILES);

Common mistakes:

forgetting to

  • set form’s enctype to multipart/form-data

  • set appropriate permissions for upload directory


with this

Try print_r($_FILES);

it shows the image

thanks a lot