Answered by : code-grepper
var fileName = "myDocument.pdf";
var fileExtension = fileName.split('.').pop(); //"pdf"
Source : | Last Update : Fri, 09 Aug 19
Answered by : yawning-yak-butdi844asxz
var ext = fileName.split('.').pop();
Source : https://stackoverflow.com/questions/680929/how-to-extract-extension-from-filename-string-in-javascript | Last Update : Wed, 11 Mar 20
Answered by : clear-crocodile-5t9988ie0a47
var ext = fileName.substr(fileName.lastIndexOf('.') + 1);
Source : https://stackoverflow.com/questions/680929/how-to-extract-extension-from-filename-string-in-javascript | Last Update : Mon, 20 Jul 20
Answered by : fancy-ferret-en695bp866gi
// Use the lastIndexOf method to find the last period in the string, and get the part of the string after that:
var ext = fileName.substr(fileName.lastIndexOf('.') + 1);
Source : https://stackoverflow.com/questions/680929/how-to-extract-extension-from-filename-string-in-javascript | Last Update : Fri, 23 Oct 20
Answered by : gorgeous-gannet-dmk7nm6ryyn2
let filename = "index.js";
let extension = filename.split(".").pop();
console.log(extension); // "js"
Source : https://sebhastian.com/javascript-filename-extension/ | Last Update : Tue, 14 Jun 22
Answered by : elegant-eland-l1jg7e3e4p33
function getFileNameWithExt(event) { if (!event || !event.target || !event.target.files || event.target.files.length === 0) { return; } const name = event.target.files[0].name; const lastDot = name.lastIndexOf('.'); const fileName = name.substring(0, lastDot); const ext = name.substring(lastDot + 1); outputfile.value = fileName; extension.value = ext;
}
Source : https://stackoverflow.com/questions/43708127/javascript-get-the-filename-and-extension-from-input-type-file | Last Update : Tue, 07 Sep 21
Answered by : fancy-fly-z8fpi7xo11pk
var fileName = "myDocument.pdf";
var fileExtension = fileName.split('.').pop(); //"pdf"
Source : | Last Update : Wed, 06 Jan 21
Answered by : dejan-ilic
file.originalname.match(/\..*$/)[0]
Source : https://regex101.com/ | Last Update : Sun, 25 Sep 22