我正在使用express 3和node.js创建一个文件上传函数。
我想获取图片的文件扩展名,以便可以将文件重命名,然后将文件扩展名附加到文件名中。
app.post('/upload', function(req, res, next) {
var is = fs.createReadStream(req.files.upload.path),
fileExt = '', // I want to get the extension of the image here
os = fs.createWriteStream('public/images/users/' + req.session.adress + '.' + fileExt);
});
如何在 Node.js 中获取图像的文件扩展名?