Saving same file twice but different location

So am trying to save a file twice but in different location. The first time it works fine but the second time I call the saveAs() function, it does not save.

Here is part of my code:


$model->avatar->saveAs(Yii::app()->basePath . '/../images/avatars/temp/' . $model->id . '.' . $extension);

$model->avatar->saveAs(Yii::app()->basePath . '/../images/avatars/' . $model->id . '.' . $extension);

You have to set the second parameter $deleteTempFile of the saveAs method to FALSE. Default value is true.




$model->avatar->saveAs(Yii::app()->basePath . '/../images/avatars/temp/' . $model->id . '.' . $extension, FALSE);

$model->avatar->saveAs(Yii::app()->basePath . '/../images/avatars/' . $model->id . '.' . $extension);



Thanks man!