Reputation: 139
I created a file upload form in yii, but for some reasons, Yii fails to validate my file size (it DOES validate my file type though). This is my controller:
$file = CUploadedFile::getInstance($model,'attachment');
if ((is_object($file) && get_class($file)==='CUploadedFile')) {
$model->attachment = $file;
if($model->validate(array('attachment')))
$model->attachment->saveAs('upload/'.$file);
}
And this is my rules:
array('attachment', 'file', 'types'=>'zip, rar, 7z','allowEmpty' => true,'maxSize'=>1024*1024*5,'tooLarge'=>'File has to be smaller than 5MB'),
Can someone tell me what is wrong here?
Upvotes: 2
Views: 3809
Reputation: 139
Thanks everyone, I managed to solve the problem myself. All I need to do is configure upload_max_filesize and post_max_size in the INI file.
Upvotes: 4