FormData 实现文件上传

本例在angular6框架下实现

HTML

<input type='file' id='upLoadFile'>

TS

let files = document.getElementById('upLoadFile').files[0]; 
const formData=new FormData();
formData.append('file',files);
let headers = new Headers();
this.http.post('/dintegrationapi/budgetItem/imp', formData,{
    headers: headers
}).subscribe((result:any)=>{
    if(result.is_success){
    
    }else{
    
    }

 

posted @ 2019-11-11 15:13  倒带_with  阅读(267)  评论(0编辑  收藏  举报