我正在使用 Express 4 和 Formidable 处理文件上传表单,但遇到了一些问题。
我想要实现的是:
-Check if file is selected and extension/format before file is uploaded to the server and abort if not .txt
-Write file "info" to db, copy file from tmp folder to dest. folder and delete tmp file.
Run Code Online (Sandbox Code Playgroud)
我的代码:
app.post('/upload', function(req, res) {
var form = new formidable.IncomingForm();
form.uploadDir = path.join(__dirname, '/uploads/tmp');
form.keepExtensions = true;
form.on('error', function(err) {
console.log(err.message);
req.flash('error', err.message);
res.redirect('/upload');
});
form.on('file', function(name, file){
var modname = file.path.split('/')[file.path.split('/').length-1]
var finals = path.join(__dirname, 'uploads/finals/' …Run Code Online (Sandbox Code Playgroud) 我试图找到一种方法来查找数组中每个观察值的多个(未知数量,但相同长度)数组的最大值比较,返回具有最大值的数组。
例子:
编辑:
A = [[2.2, 3.3, 1.3], [1.2, 5.3, 2.2], [0.3, 2.2, 5.2], etc......]
Run Code Online (Sandbox Code Playgroud)
返回
MAX = [2.2, 5.3, 5.2]
Run Code Online (Sandbox Code Playgroud)
能够检查“输入”数组的长度是否相同,但无法比较数组以找到最大值......?