file upload error

I get this error when I try to upload a file in the ‘images’ directory inside my theme folder ‘fitness’.

PHP Error

move_uploaded_file($file) [<a href=‘function.move-uploaded-file’>function.move-uploaded-file</a>]: failed to open stream: Permission denied


public function saveAs($file,$deleteTempFile=true)

179 {

180 if($this->_error==UPLOAD_ERR_OK)

181 {

182 if($deleteTempFile)

183 return move_uploaded_file($this->_tempName,$file);

184 else if(is_uploaded_file($this->_tempName))

185 return copy($this->_tempName, $file);

186 else

187 return false;

188 }

189 else

190 return false;

191 }

here is the code of upload action:

public function actionUpload()


            &#036;model=new Pix;

         // uncomment the following code to enable ajax-based validation


           if(isset(&#036;_POST['ajax']) &amp;&amp; &#036;_POST['ajax']==='pix-upload-form')


                  echo CActiveForm::validate(&#036;model);








                  &#036;file= Yii::app()-&gt;theme-&gt;baseUrl.'/images/'.&#036;model-&gt;image-&gt;name;




                         // redirect to success page







The target directory is writeable by the HTTP server process?

yes, it is writable.

Is safe mode turned on, if it is writeable but not owned by the HTTP server process then it wont work in safe mode. PHP is saying it can’t access one of the files/locations, so something is wrong at the file system level.

You might not notice that


It should be


thanks! it is working now on making this subtle change suggested by you.