13
Node.js รับนามสกุลไฟล์
ฉันกำลังสร้างฟังก์ชั่นอัพโหลดไฟล์ใน node.js ด้วย express 3 ฉันต้องการคว้านามสกุลไฟล์ของภาพ ดังนั้นฉันสามารถเปลี่ยนชื่อไฟล์และต่อท้ายนามสกุลไฟล์นั้น 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 ได้อย่างไร?