【问题标题】:How to upload image from "RichTextEditor", using Node.js?如何使用 Node.js 从“RichTextEditor”上传图像?
【发布时间】:2020-12-29 02:46:45
【问题描述】:

我在我的项目中使用 RichTextEditor。如何上传图片并使用上传的图片网址?

http://joxi.ru/52aEa1jUkkw712

【问题讨论】:

    标签: node.js vue.js rich-text-editor


    【解决方案1】:
    <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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-28
      • 1970-01-01
      • 2013-08-27
      • 2016-04-14
      • 1970-01-01
      • 2014-07-03
      • 1970-01-01
      • 2021-12-10
      相关资源
      最近更新 更多