Q:

Yii want to upload file from frontend to backend/www/images folder in yii boilerplate

Here is my code in frontend site controller to update user and i am adding user using backend so i store user images in backend/www/images folder and want to use same path for file upload when i upload user image from frontend 
My code in frontend is 
public function actionupdateuser()
 {
     $model = User::model()->findByAttributes(array('memberid' => Yii::app()->user->id));
            if (isset($_POST['User']))
            {
                $rnd = rand(0, 9999);  // generate random number between 0-9999
                $uploadedFile = CUploadedFile::getInstance($model, 'photo');
                $fileName = "{$rnd}-00-{$uploadedFile}";  // random number + file name
                $model->attributes = $_POST['User'];

                if ($model->validate())
                {
                    if (!empty($uploadedFile))
                    {
     $path = Yii::app()->request->baseUrl . '/../../backend/www/images/';
                        $uploadedFile->saveAs($path . $fileName);
                        $model->photo = $fileName;
                    }
                    if ($model->save())
                        $this->redirect(array('useraccountdetail'));
                }
                else
                {
                    echo 'eroors';
                    exit;
                }
            }

            $this->render('updateuser', array('model' => $model));
        }

Here is the error i got 
*move_uploaded_file(/simplifysupper/frontend/www/../../backend/www/images/6086-00-Penguins.jpg): failed to open stream: No such file or directory *

A:

$basePath = str_replace(DIRECTORY_SEPARATOR.'protected', "", str_replace('frontend', '', Yii::app()->basePath));
$uploadDir = 'backend/www/images/';
$uploadedFile->saveAs($basePath .$uploadDir. $fileName);

Hope this helps ;)

