yiiでファイルアップロードフォームを作成しましたが、いくつかの理由で、Yiiはファイルサイズを検証できません(ただし、ファイルタイプは検証されます)。これは私のコントローラーです:
$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);
}
そしてこれが私のルールです:
array('attachment', 'file', 'types'=>'zip, rar, 7z','allowEmpty' => true,'maxSize'=>1024*1024*5,'tooLarge'=>'File has to be smaller than 5MB'),
誰かがここで何が悪いのか教えてもらえますか?