node.js - 如何使用 Node.js 从“RichTextEditor”上传图像?
解决方案
<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>
推荐阅读
- json - tsconfig.json - 扩展 - 编译器不使用其他 tsconfig.json 文件
- scikit-learn - 高斯过程 RBF 内核使用什么各向异性方法?
- html - 使用 FOR XML PATH 在 SQL Server 中格式化颜色
- node.js - 在节点中使用 postcss 修改 css 字符串
- playframework-2.6 - 播放未将 AuthenticatorResult 识别为结果
- java - 引起:android.database.sqlite.SQLiteException:没有这样的表:食物(代码 1 SQLITE_ERROR):,编译时:SELECT * FROM food order by id asc 2
- google-apps-script - Google Apps 脚本 autoResizeRow
- npm - "npm install" 安装未使用的包
- html - 使用 css wordpress 隐藏和显示特定的 div
- python - 向熊猫中的现有列添加值