//this is my controller
function addFile(file){
alert("inside add file");
customerService.uploadCsv(file).then(function(response){
if(response=="success"){
alert("file uploaded");
}else{
alert("something went wrong");
}
},
function(error){
alet("error")
});
}
//this is my service
this.uploadCsv=function(file){
alert("inside upload csv service ");
return $http.post('http://localhost:3005/customers/csv').then(function(response){
deferred.resolve(response.data);
return deferred.promise;
},
function(error){
deferred.reject(error);
return deferred.promise;
});
};//end of uploadCsv function
I have to send file in key value,key is 'upl' and value is file.I ma taking file from view(html)