Nodejs 文件上传后处理


Nodejs 文件上传后处理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
var fs = require("fs");

var uploadFile = async function(req, res) {
try{
var file = req.files[0].path;
var data = fs.readFileSync(file,"utf-8");
var lines = data.split('\n');
for(var i = 0; i < lines.length ;i++){
var line = lines[i];
line = line.replace(/\r/g, '');
// 内容处理
}
}catch (exp){
log.error('error:' + exp);
}
}