I am trying to get rename and onFileUploadComplete to call their console log but it never does, it does however call my console in post, which is giving me a string of a file that is not there.
var express = require("express");
var multer = require("multer");
var Excel = require("exceljs");
var router = express.Router();
var fs = require('fs');
var doneUpload = false;
var displayResults = [];
var Excelfile;
router.use(multer({ dest: "./uploads/",
rename: function (fieldname, filename) {
console.log("Filename: "+filename);
return new Date().getTime() + filename;
},
onFileUploadComplete: function (file) {
saveFile = file;
console.log("onFileUploadComplete ");
doneUpload = true;
}
}).single("excelFile"));
router.get("/", function(req, res){
res.sendFile(__dirname + "/index.html");
});
router.post("/api/fileupload" ,function(req, res){
Excelfile = req.file.path;
console.log(typeof Excelfile);
res.render("results", {
displayResults: displayResults
});
});
module.exports = router;
Thanks in advance.My ultimate goal is to have a file I can pass into excel JS and currently it is saying the file is not in the correct string format. I suspect because the file is being renamed to the long string of numbers "uploads/7ab48192a1c548a3dce3b9d74cad6592" which is never pointing to an actual file. I further suspect this because I ran typeof and it is does give me back a string - just not one pointing to a file, especially if onFileUploadComplete never gets fired telling me the file is uploaded?