Trying to get the SWFUpload extension to work...


Hi all.

Like many, I’m new to Yii.

I’ve been trying to install the SWFUploader (as instructed here YIISITEBASEURL/extension/swfupload). I can upload files but it is strange because can ONLY upload files to the base of my application (i.e. but I cannot upload files to directories there or in protected.

Eventually I wish to be able to upload files to a specific folder in my home directory outside of public_html (i.e. parent directory of, or at least within a safe directory to which nobody can get access to.

Hope someone here can shed some light on what I’m doing wrong. Below I outline the steps I’m taking:

0) I created an empty folder called ‘uploadedfiles’ (755) at the base of my application (i.e.

1) I placed the release file’s (swfupload) folder in ‘

2) I placed the release file’s (handlers.js) file in ‘

4) I placed a controller (UploadsController.php) at ‘


class UploadsController extends Controller


public function filters()


   return array(

     'accessControl -upload',



public function actionUploader(){

// In case you wish to  post a variable each time a file

// is uploaded. This is good if a picture is related to an object

// and you wish to pass the ID so to related both picture

// or file to parent.

// $yourvar = 'variabletopost';

// $this->render('uploader',array('yourvar'=>$yourvar));


   // In my case is AJAX



public function actionUpload(){


     $picture_file = CUploadedFile::getInstanceByName('Filedata');

     if(!$picture_file || $picture_file->getHasError()){

    echo 'Error: Invalid File';




     $picture_name = $picture_file->name;


     $destination = Yii::getPathOfAlias('uploadedfiles').$picture_name;



     }catch(Exception $e){

    echo 'Error: ' . $e->getMessage();










5) I placed the following file (upload.php) at ‘


$uurl = $this->createUrl('uploads/upload');

$this->widget('application.extensions.swfupload.CSwfUpload', array(

    'jsHandlerUrl'=>'js/handlers.js', //Relative path





        'file_size_limit'=>'2 MB',


        'file_types_description'=>'Image Files',












        'button_text'=>'<span class="button">'.Yii::t('messageFile', 'ButtonLabel').' (Max 2 MB)</span>',

        'button_text_style'=>'.button { font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; font-size: 11pt; text-align: center; }',









<?php echo CHtml::beginForm(); ?>

<div class="form">

    <div class="row">

    <div id="divFileProgressContainer"></div>

    <div class="swfupload"><span id="swfupload"></span></div>



<?php echo CHtml::endForm(); ?>

Notes: So, when I go to I’m able to see the upload form, I’m able to initiate an upload, I’m able to see the status message “Uploading…”, and then “All Images received”. But upon checking the uploadedfiles folder reveals NO UPLOADS…Is there something I’m missing?


Fixed by changing the following:

$destination = Yii::getPathOfAlias(‘uploadedfiles’).$picture_name;


$destination = ‘uploadedfiles/’.$picture_name;