Node.js获取文件扩展名

JavaScript Node.js

DavaidTony宝儿

2020-03-24

我用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中获取图像的扩展名?

第3174篇《Node.js获取文件扩展名》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

0个回答

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android