Yii-Booster Redactor Image Upload Problem.

I’m trying to implement file uploads using the redactor editor bundled with Yii-booster. It’s a current version of redactor (Dec 2012 I believe).

The image uploads work, but after you select the file to upload the file is transferred and stored but does not show in the window to insert it into the editor area.

If you click cancel on the upload window then re-open it, the file I uploaded shows up in the list of files on the server and can be inserted.

EDIT: Got it working, here’s the controller code for those interested.


<?php echo $form->redactorRow($model,'descr', array('options' => array('imageUpload' => Yii::app()->createAbsoluteUrl('admin/event/imageUpload'),

                                                                                'imageGetJson' => Yii::app()->createAbsoluteUrl('admin/event/listImages')))); ?>[code]


    public function actionImageUpload() {

        $uploadedFile = CUploadedFile::getInstanceByName('file');

        if (!empty($uploadedFile)) {

            $rnd = rand();  // generate random number between 0-9999

            $fileName = "{$rnd}.{$uploadedFile->extensionName}";  // random number + file name

            if ($uploadedFile->saveAs(Yii::app()->basePath . '/../images/' . $fileName)) {


                $array = array(

                     'filelink' => Yii::app()->baseUrl . '/images/' . $fileName);

               // echo CHtml::image(Yii::app()->baseUrl . '/images/' . $fileName);


                echo stripslashes(json_encode($array));




        throw new CHttpException(400, 'The request cannot be fulfilled due to bad syntax');


// "ListImages" (used to browse images in the server)

    public function actionListImages() {

        $images = array();

        $handler = opendir(Yii::app()->basePath . '/../images');

        while ($file = readdir($handler)) {

            if ($file != "." && $file != "..")

                $images[] = $file;



        $jsonArray = array();

        foreach ($images as $image)

            $jsonArray[] = array(

                'thumb' => Yii::app()->baseUrl . '/images/' . $image,

                'image' => Yii::app()->baseUrl . '/images/' . $image,


        header('Content-type: application/json');

        echo CJSON::encode($jsonArray);


[color="#006400"]/* moved from General Discussion */[/color]