Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript find file extension from string

var ext =  fileName.split('.').pop();
Comment

javascript get file extension from string

// 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);
Comment

get file extention js

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;
  
}
Comment

how to get file extension in javascript

var fileName = "myDocument.pdf";
var fileExtension = fileName.split('.').pop(); //"pdf"
Comment

Get file extension in javascript

file.originalname.match(/..*$/)[0]
Comment

PREVIOUS NEXT
Code Example
Javascript :: es6 map usin index 
Javascript :: print value in jquery 
Javascript :: convert json to dataframe python 
Javascript :: how to wait a determined amount of time before doing something in js 
Javascript :: javascript date method 
Javascript :: how to use hidden in div in angular 
Javascript :: react environment 
Javascript :: divide first name and last name in javascript 
Javascript :: E: Unable to locate package npm 
Javascript :: node.js f string 
Javascript :: how to parse using express without body parser 
Javascript :: javascript if has jquery loaded 
Javascript :: how to serialize form data in js 
Javascript :: ajax load document ready 
Javascript :: javascript element read attribute 
Javascript :: how to split two digit number in javascript 
Javascript :: jquery selector this and class 
Javascript :: discordjs eval 
Javascript :: current date minus days javascript 
Javascript :: get keys of object in an array 
Javascript :: javascript get point of line intersection 
Javascript :: send message whatsapp javascript 
Javascript :: javascript - get the filename and extension from input type=file 
Javascript :: remove property from javascript object 
Javascript :: semantic ui dropdown value 
Javascript :: make a get request in node js 
Javascript :: adding border in react native 
Javascript :: nodejs mysql insert query 
Javascript :: loop array in javascript 
Javascript :: reading files with node.js 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =