JavaScript Obtenha extensão de arquivo
var fileName = "myDocument.pdf";
var fileExtension = fileName.split('.').pop(); //"pdf"
Grepper
var fileName = "myDocument.pdf";
var fileExtension = fileName.split('.').pop(); //"pdf"
var fileName = "myDocument.pdf";
var fileExtension = fileName.split('.').pop(); //"pdf"
function showType(fileInput) {
var files = fileInput.files;
for (var i = 0; i < files.length; i++) {
var name = files[i].name;
var type = files[i].type;
alert("Filename: " + name + " , Type: " + type);
}
}
var url = window.location.pathname;
var filename = url.substring(url.lastIndexOf('/')+1);
alert(filename);
<input id='inputfile' type='file' name='inputfile' onChange='getoutput()'><br>
Output Filename <input id='outputfile' type='text' name='outputfile'><br>
Extension <input id='extension' type='text' name='extension'>