我想通过 HTTP post API 上传图片。我的输入是这样的。
<input type="file" (change)="changedata($event)" name="file"/>
和 Changedata() 函数。
let fileList: FileList = event.target.files;
if (fileList.length > 0) {
let file: File = fileList[0];
let formData: FormData = new FormData();
formData.append('File', file, file.name);
this.mainservice.updateIcon(formData).subscribe(responseData=>{
console.log(' Reposnce Data ',responseData)
})
}
当我检查请求有效负载时,它不发送图像.. 请参阅 https://www.screencast.com/t/vKFKj0S3
如何在 base64 中发送图像?