【发布时间】:2020-02-01 11:50:02
【问题描述】:
我有一个网络摄像头,所以我需要捕获一张身份证并为我的 Angular 项目上传图像。任何人都建议我使用简单的 npm 库。
【问题讨论】:
-
你基本上也不需要库,像普通上传一样发送文件就可以了
标签: angular image file-upload npm-install
我有一个网络摄像头,所以我需要捕获一张身份证并为我的 Angular 项目上传图像。任何人都建议我使用简单的 npm 库。
【问题讨论】:
标签: angular image file-upload npm-install
使用formData上传方法如下:
public upload(file: any): Observable<any> {
let headers: HttpHeaders = new HttpHeaders();
const params = new HttpParams();
const formData: FormData = new FormData();
if (file) {
formData.append('file', file, file.name);
}
return this.http.put(this.Url, formData, { headers, params })
.pipe(map((response: any) => {
return response;
}));
}
【讨论】: