FormData 如何在 multipart/form-data 中获取或设置边界 - Angular [英] FormData how to get or set boundary in multipart/form-data - Angular

查看:50
本文介绍了FormData 如何在 multipart/form-data 中获取或设置边界 - Angular的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小应用程序,我必须在其中将表单数据从浏览器发布到端点.

I have a mini app, where I have to post a form data to an endpoint from browser.

这是我的帖子:

var formData = new FormData();
formData.append('blobImage', blob, 'imagem' + (new Date()).getTime());

return $http({
  method: 'POST',
  url: api + '/url',
  data: formData,
  headers: {'Content-Type': 'multipart/form-data'}
})

边界似乎是由formData添加到参数中的,但是我无法将其发送到标题中,我该怎么办?

Boundaries seems to be added by formData to the parameter, however, I cannot get it to send in the header, how should I done?

推荐答案

好吧,看来标题 ContentType 应该是未定义的,以便添加正确的边界

Well, seems that the headers ContentType should be undefined, in order to add the correct boundaries

这篇关于FormData 如何在 multipart/form-data 中获取或设置边界 - Angular的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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