[英]How to upload image from “RichTextEditor”, using Node.js?
I'm using RichTextEditor in my project.我在我的项目中使用 RichTextEditor。 How can i upload a picture and use uploaded image url?如何上传图片并使用上传的图片网址?
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.