I had some problems when I tried update a record on my application without upload again a file.
I have a form and on this form there are two fields for upload files, when I create a new record the valdation requires the files, but on update no.
When I try to update a record I receive the error:
Fatal error: Call to a member function saveAs() on a non-object in /Users/san/src/nagloria/trunk/web/public/protected/controllers/admin/RepertoryController.php on line 74
here are my actions:
public function actionCreate()
{
$piece = new Repertory;
$piece->scenario = 'create';
$this->registration($piece, $_POST['Repertory']);
$this->render('create', array('repertory' => $piece));
}
public function actionUpdate()
{
$piece = $this->loadpiece();
$this->registration($piece, $_POST['Repertory']);
$this->render('update', array('repertory' => $piece));
}
private function registration($model, $form)
{
if(isset($form))
{
$model->attributes = $form;
$model->media_file = CUploadedFile::getInstance($model, 'media_file');
$model->thumb = CUploadedFile::getInstance($model, 'thumb');
if($model->save())
{
exec("mkdir -p " . Yii::app()->basePath . "/../files/repertory/media_file/{$model->id}/");
exec("mkdir -p " . Yii::app()->basePath . "/../files/repertory/thumbs/{$model->id}/");
$model->media_file->saveAs(Yii::app()->basePath . "/../files/repertory/media_file/{$model->id}/{$model->media_file->name}");
$model->thumb->saveAs(Yii::app()->basePath . "/../files/repertory/thumbs/{$model->id}/{$model->thumb->name}");
$this->redirect('/admin/repertory/list');
}
}
}
How can I fix up this?
Thanks?

Help
This topic is locked













