FormData Upload Files

In the present embodiment achieved the framework 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{
    
    }

 

Guess you like

Origin www.cnblogs.com/gouzei/p/11835060.html