Yiibooster Redactor File Upload

Hi all.

I’m looking for some advices to get YiiBooster Redactor imageUpload widget to work properly.

I have a widget for Redactor Image Upload in my Producto _form, from Producto model:




$this->widget('bootstrap.widgets.TbRedactorJs',

    array(

      'model'=>$model,

      'attribute'=>'imagen',

      'editorOptions'=>array(

          'imageUpload' => $this->createUrl('site/uploadpicture'),

          'imageGetJson'=> $this->createUrl('site/getimagedata', array('folder'=>'producto')),

          'width'=>'100%',

          'height'=>'400px',

          'buttons'=>array('image'),

   	)

   ));



I have two functions in my siteController for getting image data and for uploading the image, but I’m stuck here.

I can get the actionGetImageData in my siteController, that gets a JSON ‘fake’ data, just for testing purposes, and another function in same controller for uploading the image file, to copy the image from tmp to /images/productos.

I can see in firebug the JSON array, but don’t know how to pass the right variables to GetImageData nor UploadPicture.

Anyway, I can get the ‘fake’ image uploaded to the widget via ‘filelink’ => ‘/images/producto/3dsac.jpg’ in actiongetImageData, then in uploadPicture, so I can ‘see’ the ‘uploaded’ image in my _form widget, but filelink is ‘handcoded’.





		public function actionGetImageData()

		{

			echo json_encode(array(

		array(

		'folder' => $_GET['folder'], // optional

			'image' => CUploadedFile::getInstance($picture,'name'),

			'filelink' => '/images/producto/3dsac.jpg',

			'thumb' => '/images/producto/3dsacthumb.jpg',

			'title' => 'Title1', // optional	    	

		));

		}







		public function actionUploadPicture()

		{

// I think copy from tmp to '/images/producto' should be done here

// then pass data to the JSON array


// actually I can get 'right' data from this JSON

   		echo json_encode(array( [/size]

				array( 

             		'error'=>$_FILES['file']['error'], 

             		'name'=>$_FILES['file']['name'], 

             		'tmp_name'=>$_FILES['file']['tmp_name'], 

             		'filetype'=>$_FILES['file']['type'],

             		'size'=>$_FILES['file']['size'],

             		'filelink' => '/images/producto/3dsac.jpg',

     			),

 			));		


		}



It’s supposed to upload the image in UploadPicture, then return the data to productoController.

It would be nice if somebody can point me in the right direction.

Thanks in advance.