Dear All,
I am trying to combine CKEditor3 with a forum program. My question now is how can I show a image from local PC file into the textarea controled by CK?
As CKEditor offers a WYSIWYG input area; so before the user press the submit button to upload and save his post into the forum's DB; I just want to show her or his attached image file from local with the help of CK's api and Javascript only (show as a immediately WYSIWYG-preview). But I do not know how to do it?
Currently, I have attached CK successfully with my target <textarea> by CKEDITOR.replace() function and I have edited ckeditor\plugins\image\dialogs\image.js to turn on the Upload button but I do not quite understand how can I use CK's api to load the image from local for preview??
For trying to show image with Javascript from local file, I have done a simple JS test under Firefox and it works as below,
<head> <style type="text/css"> #prevImage { border: 3px solid #ccc; } </style> <script type="text/javascript"> function previewImg(file) { var elm=document.getElementById('prevImage'); if (elm) { elm.src=file.files.item(0).getAsDataURL(); } if (elm.src.length > 0) elm.style.display = 'block'; } </script> </head>