0
我从我的客户端JavaScript上传一个csv文件作为发布请求到我的节点服务器。我也能够在nodejs服务器上处理请求。请帮助我获取文件并解析服务器端的文件。该文件将是一个csv文件,我需要解析文件并读取文件的内容。在nodejs中处理表单数据
我附上了源代码片段,用于在客户端和服务器端上传文件以供参考。
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
});
}
在服务器的NodeJS:
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);
});
[Node/Express文件上传]的可能重复(http://stackoverflow.com/questions/23691194/node-express-file-upload) – callmekatootie
你给了一些信息。所以你可以做一个console.log关于req.body和req.files,看看这个文件在哪里。我问这个问题是因为使用express.4.0 +我们不能使用bodyparser来处理多形式的数据。 – harryy000