I am uploading a csv file from my client side javascript as Post request to my node server. I am able to handle the request on the nodejs server as well. Please help me in fetching the file and parsing the file on the server side. The file will be a csv file and I need to parse the file and read the contents of the file.
I am attaching the source code snippet for uploading the file on the client side as well as the server side below for reference.
myAngularApp.service('fileUpload', ['$http', function ($http) {
this.uploadFileToUrl = function(file, uploadUrl){
var fd = new FormData();
fd.append('file', file);
$http.post(uploadUrl, fd, {
transformRequest: angular.identity,
headers: {'Content-Type': undefined}
})
.success(function(){
// handling on success data
})
.error(function(){
// handling on error data
});
}
On NodeJs server:
router.post('/filter-reports', function(req, res) {
console.log('Came inside the Node js router.. Now.. its all up to me to format the data....');
console.log(req);
});