Туплю после отпуска по страшному и никак не могу понять в чем ошибка...
Модель:
Код: Выделить всё
<?php
class OrderFastForm extends CFormModel
{
public $name;
public $email;
public $phone;
public $body;
public $attachment;
public function rules()
{
return array(
array('name, phone, attachment', 'required','message'=>Yii::t('lan','Поле "{attribute}" не может быть пустым.')),
array('email', 'email','message'=>Yii::t('lan','Поле "{attribute}" заполнено неверно.')),
array('attachment', 'file', 'allowEmpty'=>true, 'types'=>'jpg,jpeg,gif,png,doc,docx,pdf,txt,xls,xlsx,rtf', 'maxSize'=>1024 * 1024 * 2),
);
}
public function attributeLabels()
{
return array(
'name' => Yii::t('lan','Имя'),
'body' => Yii::t('lan','Текст сообщения'),
'email' => 'Email',
'phone' => 'Номер телефона',
'attachment' => 'Файл',
);
}
}
Код: Выделить всё
public function actionOrderFast()
{
$model = new OrderFastForm();
if(isset($_POST['OrderFastForm']))
{
$model->attributes=$_POST['OrderFastForm'];
$file = CUploadedFile::getInstance($model,'attachment');
if ((is_object($file) && get_class($file)==='CUploadedFile'))
$model->attachment = $file;
//ВОТ ЗДЕСЬ ОШИБКА - Unable to upload the file "12313587-3.rtf" because of an unrecognized error.
// /yii/validators/CFileValidator.php(215)
if($model->validate())
{
$filePath=Yii::getPathOfAlias('webroot').'/upload/ordersFast/';
$model->attachment->saveAs($filePath.mktime().'_'.$model->attachment->name);
}
}
$this->render('orderFast',array('model'=>$model));
}