Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript find file extension from string

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

how to get the extension from filename using javascript

var ext = fileName.substr(fileName.lastIndexOf('.') + 1);
Comment

JavaScript - How to get the extension of a filename

let filename = "index.js";
let extension = filename.split(".").pop();

console.log(extension); // "js"
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 :: check if not checked vanila js 
Javascript :: how to get the next item in map() js 
Javascript :: jquery uncheck all other checkboxes when one is checked 
Javascript :: js date after 1 year 
Javascript :: username validation formik react yup 
Javascript :: javascript scroll function 
Javascript :: number format in javascript 
Javascript :: onclick checkbox hide div and unchecked show div 
Javascript :: pad js 
Javascript :: await fetch in react 
Javascript :: jquery ajax while loading 
Javascript :: how to get mat input value on keyup javascript 
Javascript :: get previous route 
Javascript :: javascript check if element is overflowing 
Javascript :: foreach object js 
Javascript :: js do every x seconds 
Javascript :: pass an array to javascript in asp net core list 
Javascript :: Javascript file in html angeben 
Javascript :: vue select option get attribute 
Javascript :: console.table javascript 
Javascript :: jquery find id with string at end 
Javascript :: javascript regex extract url from string 
Javascript :: reset form function javascript 
Javascript :: javascript falsy values 
Javascript :: jQuert latest cdn 
Javascript :: inline style in nextjs 
Javascript :: javascript object entries 
Javascript :: js find in array and remove 
Javascript :: jqurey cdn 
Javascript :: javascript switch 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =