file upload not required

I want file upload optional in my form. In my model file, in ‘rules’ I have coded:


array('imageData','file','types'=>'jpg')

,

but I have not included image data in the ‘required’ rule. And I am not storing the uploaded file in DB. But if I submit a form without the uploaded image, I get the validation error that ‘upload file is required’.

The program works fine if I comment out the above code, but then I cannot validate the file type. Any help is welcome.

To that rule you can add


 'allowEmpty'=>true

Thanks. The final code is:


array('imageData','file','types'=>'jpg', 'allowEmpty'=>true),

thanks alot guys, just what i was looking for, also thanks for posting final solution! :)

Thanx i was looking for this too :)

Thanks, just what i was looking for.