问题描述
我正在尝试在我的应用程序上添加从 angular 到 ASP.NET Core 的上传进度。但不幸的是,我从 100
获得 this.progressstat
状态,即使上传状态仍然是 IN PROGRESS 多个文件上传。请帮忙。
在我的 Angular 服务中,
public upload(files): void {
var formData = new FormData()
// my files is a collection
for(let i = 0; i < files.length; i++){
formData.append("file",files[i],files[i].name)
}
return this.http.request(new HttpRequest('post','api/upload',formData,{ reportProgress: true }))
}
这是使用它的组件中的示例方法。
public uploadFile(event){
this.uploadService.upload(files).subscribe((response:any) => {
if(response.type === HttpEventType.UploadProgress){
this.progressstat = Math.Round(100 * response.loaded / response.total)
this.status = "Uploading"
}
if(response.type === HttpEventType.Complete){
this.progressstat = null // back to zero
this.status = "Done"
}
})
}
在我的后端 ASP.NET Core 方面,
[HttpPost]
public async Task<IActionResult> Upload([FromForm(Name = "file")]List<IFormFile> files){
...
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)