Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.

KCFinder & Json responses #155

Open
ChristopheZenner opened this issue Jan 22, 2017 · 7 comments
Open

KCFinder & Json responses #155

ChristopheZenner opened this issue Jan 22, 2017 · 7 comments

Comments

@ChristopheZenner
Copy link

ChristopheZenner commented Jan 22, 2017

Is it an option in the current version of KCFinder to get a json response after uploading an image? I tried version 2.51, 3.12 and 3.20 test 2.

I'm using CKEditor with the Upload Image plugin for drag&drop upload and KCFinder. File is uploading using drag&drop as it should be, but then I get an "Incorrect server response" error.

In the demo (http://sdk.ckeditor.com/samples/fileupload.html#uploading-dropped-and-pasted-images) using CKFinder, I see for example the following json response with firebug:
{"fileName":"golf.jpg","uploaded":1,"url":"/userfiles/files/golf.jpg"} which works perfectly.

In my project using KCFinder, I get for example the following response:

<script type='text/javascript'> var par = window.parent, op = window.opener, o = (par && par.CKEDITOR) ? par : ((op && op.CKEDITOR) ? op : false); if (o !== false) { if (op) window.close(); o.CKEDITOR.tools.callFunction(0, '/userfiles/images/contact%281%29.jpg', ''); } else { alert(''); if (op) window.close(); } </script>

which isn't working because no json.

Any help would be very much appreciated...

@coxta
Copy link

coxta commented Mar 10, 2017

Having the same issue...

@ChristopheZenner
Copy link
Author

I've changed kcfinder\core\class\uploader.php.
Still testing and probably not the best solution, but everything is working now.

  • function callBack: removed html and body tags from echo (line 712)
  • function callBack_ckeditor: see attached file (line 716)

uploader.zip

@NilsBe
Copy link

NilsBe commented Apr 5, 2018

I had the same issue.
The changes in uploader.php are working for Upload Image by drag&drop but when uploading an image in CKEditor the usual way:
Image Button in Toolbar, Upload Tab, Choose File and "Send to Server"
then I get a weird Output in that dialog. There I get an iframe with the plain json result. (iframe too small, json not visible in this screenshot)

image

seamuslee001 added a commit to seamuslee001/kcfinder that referenced this issue Apr 27, 2018
…e if requested by using the url param format=json
@seamuslee001
Copy link

I faced the same issue after updating to the latest CKEditor, I was able to get it working using this PR #168 and adding &format=json into the upload url. Note the file browser still needs the javascript i believe

balrok added a commit to balrok/kcfinder that referenced this issue Jun 26, 2018
if requested by using the url param format=json

From: Seamus Lee <[email protected]>
Date: Sat, 28 Apr 2018 07:34:19 +1000
@shauryaverma4296
Copy link

image

I'm getting an issue which says incorrect server response while drag and drop.
image

The response which I'm getting is '<script type="text/javascript">window.parent.OnUploadCompleted(201, 'https://www.proprofs.com/api/ckeditor_images/image(110).png', 'image(110).png', '') ;</script>' which is not a json. Please can you tell me exactly how and from where I'm getting this response . And How will i resolve this so that i can get a json respone.

@ChristopheZenner
Copy link
Author

ChristopheZenner commented Nov 21, 2018

public_html.zip

These are the files in the correct file structure that work fine for me in my projects. I can upload images by drag and drop in ckeditor, I can manually select a file and click "send it to the server", I can upload in kcfinder; browse file and upload, and even drag and drop in kcfinder.

(you have to change the upload authorisation in /kcfinder/conf/config.php. You can use a session as in my example or maybe someting else...)

Kind regards
Christophe

@afzafri
Copy link

afzafri commented Feb 10, 2020

public_html.zip

These are the files in the correct file structure that work fine for me in my projects. I can upload images by drag and drop in ckeditor, I can manually select a file and click "send it to the server", I can upload in kcfinder; browse file and upload, and even drag and drop in kcfinder.

(you have to change the upload authorisation in /kcfinder/conf/config.php. You can use a session as in my example or maybe someting else...)

Kind regards
Christophe

Thank you so much for this. I was having trouble with "invalid server response" when paste image into CKEDITOR. I just replace the original kcfinder/core/class/uploader.php.php with yours and now it's working great!

michield added a commit to michield/phplist-plugin-ckeditor that referenced this issue Apr 24, 2020
michield added a commit to michield/phplist-plugin-ckeditor that referenced this issue Apr 24, 2020
Signed-off-by: Michiel Dethmers <[email protected]>
(cherry picked from commit 4de22de)
thestanislav added a commit to thestanislav/kcfinder that referenced this issue Feb 10, 2021
Resolve sunhater#155 by allowing kcfinder to send back a JSON response if req…
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants