Redactor Upload Image


I would like to know anyone know how to use redactor image upload?Is there any example?


look at janisto’s ycm module.

He has implemented a nice "universal" (meaning that you can call it for all your models/attribute that are defined as text in your db) way to use redactor with the upload feature.

here is source code.

I just committed easy to use actions for Redactor widget.

Check out

Modify the actions to your own taste.

Looks good.

Thank you

I’m trying to upload images using this actions from github (

And a uploads folder is created with the image in it, and in the textarea I’m getting this:


Is this how it should work, or am i missing something ?

Are you using file or image upload action?

How did you configure the controller and view?

Hi janisto

i am using this code in my view(_form)



        $this->widget('ImperaviRedactorWidget', array(

            // You can either use it for model attribute

            'model' => $model,

            'attribute' =>$attribute,

            // or just for input field


            'name' => 'description',

            // Some options, see

            'options' => array(

                'fileUpload' => Yii::app()->createUrl('post/fileUpload', array(

                    'attr' => $attribute,


                'fileUploadErrorCallback' => new CJavaScriptExpression(

                        'function(obj,json) { alert(json.error); }'


                'imageUpload' => Yii::app()->createUrl('post/imageUpload', array(

                    'attr' => $attribute,


                'imageUploadErrorCallback' => new CJavaScriptExpression(

                        'function(obj,json) { alert(json.error); }'





and following code in my controller

 public function actions()


        return array(


















but i got this error

SyntaxError: JSON.parse: expected property name or ‘}’

return window.JSON.parse( data );

please help me where i m wrong…sorry for my poor English

Hi Amjad,

I have faced the same issue and fixed.

Do you have a folder named "actions" in extensions/imperavi-redactor-widget ?

If not you can download it from the link provided by janisto above

That will fix your issue