[Vuejs]-How to upload image from "RichTextEditor", using Node.js?

0๐Ÿ‘

โœ…

<textarea id="rich_editor" placeholder="Type Message"></textarea>

<script>
   let editorcfg = {}
   editorcfg.file_upload_handler = uploadEditorImage();
   let editor = new RichTextEditor("#rich_editor", editorcfg);

   function uploadEditorImage(file, callback, optionalIndex, optionalFiles) {
       let url = "/notification/image/upload";
       let formData = new FormData();
       formData.append("image", file);

       axios.post(url, formData, {
           headers: {
              "Content-Type": "multipart/form-data"
           }
       }).then(response => {
            if (response.data.success) {
                 Swal.fire(
                     "Success!",
                     "Image has been uploaded.",
                     "success"
                 );

              callback(response.data.url);
           }
      });
  }    
</script>

Leave a comment