Failed to set unsafe attribute "file"

How do I define file as safe attribute if my model does not have a file attribute

I have a model where I store a name of a file which I upload using same models form.

inside form:




...

<div class="row">

	<?php echo CHtml::error($model, 'file')?>

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

</div>

...



I get this error inside my application log:

[warning] [application] Failed to set unsafe attribute "file" of "Carpics".

Can I make file safe at all if its not part of my model?

so how can I avoid that error?

Why is it not part of your model? Just add it in…

Pls, check wiki page about file uploading:

http://www.yiiframework.com/wiki/2/

In your Model, you can set the "safe" be true.

like above.





public function rules() {


    return array(


        array('file', 'file', 'types'=&gt;'zip', [b]'safe'=&gt;true[/b]),


    );


}