rename files in yii

I have two folders for images.

Folder upload located in folder protected and folder images located in root.

I use function rename for transfer and rename images. but I get this error:

The system cannot find the path specified.

this is my code:


rename(Yii::app()->basePath.'/uploads/'.$uploadImagesName , Yii::app()->baseUrl().'/images/'imageName);

When two folders located in protected or root it’s work.

I can use $_SERVER[‘DOCUMENT_ROOT’].

What can I use Instead of $_SERVER[‘DOCUMENT_ROOT’]?

change this

Yii::app()->baseUrl().’/images/'imageName

for this

Yii::app()->baseUrl().’/images/’ . $imageName

Thank You for reply.

I accidentally deleted $ when I changed name of variable.

Yii::app()->baseUrl() not work.

It is solution:

Yii::getPathOfAlias(‘webroot’).’/images/’ . $imageName


<?php

// dirname() will take you one directory up

rename(Yii::app()->basePath.'/uploads/'.$uploadImagesName , dirname(Yii::app()->basePath).'/images/'.$imageName);