如何从ionic中将带有http帖子形式的图像从ionic发送到node.js? [英] How to send an image with an form in http post from ionic to node.js?

查看:47
本文介绍了如何从ionic中将带有http帖子形式的图像从ionic发送到node.js?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想发送带有表单数据的图像,例如http帖子中的名称和描述.

I want to send image with form data like name and description in http post.

var body={
 name:name,
 description:desc
}
this.http.post("url",body).subscribe(val=>{
    console.log(val);
})

我如何发送图像以及HTTP帖子中的数据?

How can i send an image along with the data in HTTP post ?

推荐答案

您可以使用 FormData

const formData = new FormData()
formData.append('file', imgBlob, filename)
this.http.post('url', formData)

这篇关于如何从ionic中将带有http帖子形式的图像从ionic发送到node.js?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆