java - CKEditor Image Upload Not working using javascript -


i working in java , javascript, using ckeditor4.2 facing 1 issue while uploading image.

i have gone through following on stackoverflow @don jones

start registering custom browser/uploader when instantiate ckeditor. can designate different urls image browser vs. general file browser.

<script type="text/javascript"> ckeditor.replace('content', {     filebrowserbrowseurl : '/browser/browse/type/all',     filebrowseruploadurl : '/browser/upload/type/all',     filebrowserimagebrowseurl : '/browser/browse/type/image',     filebrowserimageuploadurl : '/browser/upload/type/image',     filebrowserwindowwidth  : 800,     filebrowserwindowheight : 500 }); </script> 

your custom code receive parameter called ckeditorfuncnum. save - that's callback function. let's put $callback.

when selects file, run javascript inform ckeditor file selected:

window.opener.ckeditor.tools.callfunction(<?php echo $callback; ?>,url) 

where "url" url of file picked. optional third parameter can text want displayed in standard alert dialog, such "illegal file" or something. set url empty string if third parameter error message.

ckeditor's "upload" tab submit file in field "upload" - in php, goes $_files['upload']. ckeditor wants server output complete javascript block:

$output = '<html><body><script type="text/javascript">window.parent.ckeditor.tools.callfunction('.$callback.', "'.$url.'","'.$msg.'");</script></body></html>'; echo $output; 

again, need give callback parameter, url of file, , optionally message. if message empty string, nothing display; if message error, url should empty string.

now issue

i've followed instructions below, the server outputting javascript block above... problem ckeditor isn't doing it, text showing in upload tab, , not switching tabs , taking url... want image display in preview section. there config, or plugin callback need make sure enabled?

thanks please help

@ilia shakitko hey solution got here is.

use commonsmultipartfile getting uploaded file.then convert file bytes write bufferedoutputstream object.then upload server (s3 / own server) , write below code

url downloaded url

string url;            string script = "<script type='text/javascript'>"                          + " window.parent.ckeditor.tools.callfunction(1, '" + url + "', '');" + "</script>";            printwriter out = null;         try {             out = res.getwriter();         } catch (ioexception e) {             // todo auto-generated catch block             e.printstacktrace();         }           out.println(script); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -