i am trying to upload image through ckeditor 4
when i press send it the server
getting this Error Incorrect Server Response
here is my controller
public function mediauploadpost(Request $request){
$CKEditor = $request->input('CKEditor');
$funcNum = $request->input('CKEditorFuncNum');
$message = $url = '';
if (Input::hasFile('upload')) {
$file = Input::file('upload');
if ($file->isValid()) {
$filename =rand(1000,9999).$file->getClientOriginalName();
$file->move(public_path().'/wysiwyg/', $filename);
$url = url('wysiwyg/' . $filename);
} else {
$message = 'An error occurred while uploading the file.';
}
} else {
$message = 'No file uploaded.';
}
return '<script>window.parent.CKEDITOR.tools.callFunction('.$funcNum.', "'.$url.'", "'.$message.'")</script>';
}
Remove this one
$res = "<script>window.parent.CKEDITOR.tools.callFunction(" .$funcNum. "," . $url . "," .$message. ")</script>"
Use this code in your return .
return response()->json([ 'fileName' => 'your file name put here', 'uploaded' => false, 'url' => $url, ]);
I had this same issue recently, and the solution was to add this line to my ckeditor-config.js
file:
config.filebrowserUploadMethod = 'form';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With