Angular 5 Formdata以ÄÖÜ作为价值观

时间:2018-01-26 13:22:30

标签: angular post utf-8 header form-data

我想将文件提升到服务器。 所以我将它们附加到formdata

  let formData: FormData = new FormData();
  formData.append('value1', 'ÖÄÜ');
  formData.append('uploadFile', file, file.name);

并尝试将它们发布到服务器

 this.http.post(`uploadURL`, formData)
        .subscribe(
        data => console.log('success'),
        error => console.log(error)
        )

但在帖子中这些Chars显示错误(文本文件中的部分除外)

-----------------------------
Content-Disposition: form-data; name="value1"

ÃÃÃ
-----------------------------
Content-Disposition: form-data; name="uploadFile"; filename="ÃÃÃ.txt"
Content-Type: text/plain

ÖÄÜ
-------------------------------

但是当我停止在formdata中添加一个文件时,ÄÖÜ显示正常。

-----------------------------
Content-Disposition: form-data; name="value1"

ÖÄÜ
-----------------------------
Content-Disposition: form-data; name="uploadFile"; filename="ÖÜÄ.txt"

-------------------------------

0 个答案:

没有答案