The official documentation is less than clear – what’s the correct way to integrate a custom file browser/uploader with CKEditor? (v3 – not FCKEditor)
The official documentation is less than clear – what’s the correct way to integrate
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Start by registering your custom browser/uploader when you instantiate CKEditor. You can designate different URLs for an image browser vs. a general file browser.
Your custom code will receive a GET parameter called CKEditorFuncNum. Save it – that’s your callback function. Let’s say you put it into
$callback.When someone selects a file, run this JavaScript to inform CKEditor which file was selected:
Where “url” is the URL of the file they picked. An optional third parameter can be text that you want displayed in a standard alert dialog, such as “illegal file” or something. Set url to an empty string if the third parameter is an error message.
CKEditor’s “upload” tab will submit a file in the field “upload” – in PHP, that goes to $_FILES[‘upload’]. What CKEditor wants your server to output is a complete JavaScript block:
Again, you need to give it that callback parameter, the URL of the file, and optionally a message. If the message is an empty string, nothing will display; if the message is an error, then url should be an empty string.
The official CKEditor documentation is incomplete on all this, but if you follow the above it’ll work like a champ.