Yii Framework Forum: Redactor Image Upload - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Redactor Image Upload Rate Topic: -----

#1 User is offline   Wilbo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 52
  • Joined: 06-September 13

Posted 14 October 2013 - 03:09 PM

Hi there,

I'm struggling with redactor, specifically the image upload.
I'm sure this is something 99% of Yii projects must need so I'm hoping someone can help me.
I've setup Yii-redactor as here, and got it working apart from the image upload.

When I try to upload an image the uploader spins briefly and then stops and says 'no file chosen'.
The console says:
POST http://localhost/holters_v1_3/admin/property/imageUpload 400 (Bad Request)  


Can someone help me out please? I've been bangin my head agaist this for three days now.
This thread from last year seems to describe the same problem but with no solution.

Thanks in advance
0

#2 User is offline   Fran├žois Gannaz 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 87
  • Joined: 24-November 09

Posted 15 October 2013 - 10:28 AM

Please post the code that calls the widget, especially the 'imageUpload' line.

The URL seems wrong. You didn't explain what is your root URL or your expected controller, but I guess the right URL would be "http://localhost/holters_v1_3/someController/imageUpload".
0

#3 User is offline   Wilbo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 52
  • Joined: 06-September 13

Posted 18 October 2013 - 05:23 AM

OK, I finally got it working by looking at the image uplad function from Janitso's YcmModule. The code is here for anyone who interested.

I think the key that I was missing was this line:
// Make Yii think this is a AJAX request.
$_SERVER['HTTP_X_REQUESTED_WITH']='XMLHttpRequest';


And if you need it the code to render redactor in the view:
$this->widget('ext.redactor.ERedactorWidget',array(
					'model'=>$model,
					'attribute'=>'main_content',
					'options'=>array(
						'lang'=>'en',
						'imageUpload'=>Yii::app()->createUrl('admin/page/redactorImageUpload',array(
                                                                'name'=>get_class($model),
                                                                'attr'=>'main_content')
                                                        ),
						'uploadCreate'=>true,
					),
				));

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users