upload image to ckeditor in laravel Incorrect server response












1















i am trying to upload image through ckeditor 4
enter image description here



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>';
}









share|improve this question



























    1















    i am trying to upload image through ckeditor 4
    enter image description here



    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>';
    }









    share|improve this question

























      1












      1








      1


      1






      i am trying to upload image through ckeditor 4
      enter image description here



      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>';
      }









      share|improve this question














      i am trying to upload image through ckeditor 4
      enter image description here



      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>';
      }






      ckeditor laravel-5.6






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 17 '18 at 9:45









      Sid HeartSid Heart

      318318




      318318
























          3 Answers
          3






          active

          oldest

          votes


















          1














          I had this same issue recently, and the solution was to add this line to my ckeditor-config.js file:



          config.filebrowserUploadMethod = 'form';





          share|improve this answer































            0














            $res = "<script>window.parent.CKEDITOR.tools.callFunction(" .$funcNum.  "," . $url . "," .$message. ")</script>"

            return response()->json(['data' => $res]);





            share|improve this answer





















            • 1





              While this may solve the question, a more comprehensive answer would be to explain what the error was and how this solution fixes that.

              – Ross
              Aug 17 '18 at 18:40






            • 1





              While this code snippet may solve the question, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.

              – 31piy
              Aug 18 '18 at 5:20











            • Thanks for replying me but its not working i found $CKEditor = $request->input('CKEditor'); and $funcNum = $request->input('CKEditorFuncNum'); both request coming null how to fix this

              – Sid Heart
              Aug 18 '18 at 10:58





















            0














            If you are using java as your backend server: return string response:



             "{n " +
            " "uploaded": 1,n" +
            " "fileName": "foo.jpg",n" +
            " "url": "/files/foo.jpg"n" +
            "}"


            See this link fro more information.
            Also remember to to have annotation: produces = MediaType.TEXT_HTML_VALUE over your rest API.






            share|improve this answer























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51892652%2fupload-image-to-ckeditor-in-laravel-incorrect-server-response%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              I had this same issue recently, and the solution was to add this line to my ckeditor-config.js file:



              config.filebrowserUploadMethod = 'form';





              share|improve this answer




























                1














                I had this same issue recently, and the solution was to add this line to my ckeditor-config.js file:



                config.filebrowserUploadMethod = 'form';





                share|improve this answer


























                  1












                  1








                  1







                  I had this same issue recently, and the solution was to add this line to my ckeditor-config.js file:



                  config.filebrowserUploadMethod = 'form';





                  share|improve this answer













                  I had this same issue recently, and the solution was to add this line to my ckeditor-config.js file:



                  config.filebrowserUploadMethod = 'form';






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 12 '18 at 16:47









                  DisgruntledGoatDisgruntledGoat

                  40.6k56176263




                  40.6k56176263

























                      0














                      $res = "<script>window.parent.CKEDITOR.tools.callFunction(" .$funcNum.  "," . $url . "," .$message. ")</script>"

                      return response()->json(['data' => $res]);





                      share|improve this answer





















                      • 1





                        While this may solve the question, a more comprehensive answer would be to explain what the error was and how this solution fixes that.

                        – Ross
                        Aug 17 '18 at 18:40






                      • 1





                        While this code snippet may solve the question, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.

                        – 31piy
                        Aug 18 '18 at 5:20











                      • Thanks for replying me but its not working i found $CKEditor = $request->input('CKEditor'); and $funcNum = $request->input('CKEditorFuncNum'); both request coming null how to fix this

                        – Sid Heart
                        Aug 18 '18 at 10:58


















                      0














                      $res = "<script>window.parent.CKEDITOR.tools.callFunction(" .$funcNum.  "," . $url . "," .$message. ")</script>"

                      return response()->json(['data' => $res]);





                      share|improve this answer





















                      • 1





                        While this may solve the question, a more comprehensive answer would be to explain what the error was and how this solution fixes that.

                        – Ross
                        Aug 17 '18 at 18:40






                      • 1





                        While this code snippet may solve the question, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.

                        – 31piy
                        Aug 18 '18 at 5:20











                      • Thanks for replying me but its not working i found $CKEditor = $request->input('CKEditor'); and $funcNum = $request->input('CKEditorFuncNum'); both request coming null how to fix this

                        – Sid Heart
                        Aug 18 '18 at 10:58
















                      0












                      0








                      0







                      $res = "<script>window.parent.CKEDITOR.tools.callFunction(" .$funcNum.  "," . $url . "," .$message. ")</script>"

                      return response()->json(['data' => $res]);





                      share|improve this answer















                      $res = "<script>window.parent.CKEDITOR.tools.callFunction(" .$funcNum.  "," . $url . "," .$message. ")</script>"

                      return response()->json(['data' => $res]);






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Aug 17 '18 at 18:01

























                      answered Aug 17 '18 at 17:52









                      Tornike MenabdeTornike Menabde

                      11




                      11








                      • 1





                        While this may solve the question, a more comprehensive answer would be to explain what the error was and how this solution fixes that.

                        – Ross
                        Aug 17 '18 at 18:40






                      • 1





                        While this code snippet may solve the question, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.

                        – 31piy
                        Aug 18 '18 at 5:20











                      • Thanks for replying me but its not working i found $CKEditor = $request->input('CKEditor'); and $funcNum = $request->input('CKEditorFuncNum'); both request coming null how to fix this

                        – Sid Heart
                        Aug 18 '18 at 10:58
















                      • 1





                        While this may solve the question, a more comprehensive answer would be to explain what the error was and how this solution fixes that.

                        – Ross
                        Aug 17 '18 at 18:40






                      • 1





                        While this code snippet may solve the question, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.

                        – 31piy
                        Aug 18 '18 at 5:20











                      • Thanks for replying me but its not working i found $CKEditor = $request->input('CKEditor'); and $funcNum = $request->input('CKEditorFuncNum'); both request coming null how to fix this

                        – Sid Heart
                        Aug 18 '18 at 10:58










                      1




                      1





                      While this may solve the question, a more comprehensive answer would be to explain what the error was and how this solution fixes that.

                      – Ross
                      Aug 17 '18 at 18:40





                      While this may solve the question, a more comprehensive answer would be to explain what the error was and how this solution fixes that.

                      – Ross
                      Aug 17 '18 at 18:40




                      1




                      1





                      While this code snippet may solve the question, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.

                      – 31piy
                      Aug 18 '18 at 5:20





                      While this code snippet may solve the question, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.

                      – 31piy
                      Aug 18 '18 at 5:20













                      Thanks for replying me but its not working i found $CKEditor = $request->input('CKEditor'); and $funcNum = $request->input('CKEditorFuncNum'); both request coming null how to fix this

                      – Sid Heart
                      Aug 18 '18 at 10:58







                      Thanks for replying me but its not working i found $CKEditor = $request->input('CKEditor'); and $funcNum = $request->input('CKEditorFuncNum'); both request coming null how to fix this

                      – Sid Heart
                      Aug 18 '18 at 10:58













                      0














                      If you are using java as your backend server: return string response:



                       "{n " +
                      " "uploaded": 1,n" +
                      " "fileName": "foo.jpg",n" +
                      " "url": "/files/foo.jpg"n" +
                      "}"


                      See this link fro more information.
                      Also remember to to have annotation: produces = MediaType.TEXT_HTML_VALUE over your rest API.






                      share|improve this answer




























                        0














                        If you are using java as your backend server: return string response:



                         "{n " +
                        " "uploaded": 1,n" +
                        " "fileName": "foo.jpg",n" +
                        " "url": "/files/foo.jpg"n" +
                        "}"


                        See this link fro more information.
                        Also remember to to have annotation: produces = MediaType.TEXT_HTML_VALUE over your rest API.






                        share|improve this answer


























                          0












                          0








                          0







                          If you are using java as your backend server: return string response:



                           "{n " +
                          " "uploaded": 1,n" +
                          " "fileName": "foo.jpg",n" +
                          " "url": "/files/foo.jpg"n" +
                          "}"


                          See this link fro more information.
                          Also remember to to have annotation: produces = MediaType.TEXT_HTML_VALUE over your rest API.






                          share|improve this answer













                          If you are using java as your backend server: return string response:



                           "{n " +
                          " "uploaded": 1,n" +
                          " "fileName": "foo.jpg",n" +
                          " "url": "/files/foo.jpg"n" +
                          "}"


                          See this link fro more information.
                          Also remember to to have annotation: produces = MediaType.TEXT_HTML_VALUE over your rest API.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Sep 19 '18 at 13:58









                          Suvriti GandhiSuvriti Gandhi

                          556




                          556






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51892652%2fupload-image-to-ckeditor-in-laravel-incorrect-server-response%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Full-time equivalent

                              さくらももこ

                              13 indicted, 8 arrested in Calif. drug cartel investigation