jQuery $ .post在请求中上传图片

时间:2019-07-24 10:56:21

标签: jquery post upload multipartform-data multer

我在后端服务上使用了multer。 (API可以正常工作。)

这是我的jquery代码,但我希望它上传图像。

代码:

var data = CKEDITOR.instances.editor.getData();
var title = document.getElementById("title").value;
var duration = document.getElementById("duration").value;
var imagePath = document.getElementById("imagePath").value;
$.post("http://localhost:3123/p/content/add",{
    title: title,
    duration: duration,
    post: data,
    imagePath: imagePath
})
.done(function(data,status){
    console.log(data);
})
.fail(function(xhr, status, error) {
    console.log(error);
});

似乎是什么问题? 预先感谢!

0 个答案:

没有答案