How to get file extension using javascript/jquery
Created at 16-Jul-2021 ,
By samar
How to get file extension using javascript/jquery
Through the use of the programming language, we will work together to solve the "How to get file extension using javascript/jquery" puzzle in this lesson.
You can get file extension in HTML using javascript/jquery function. You have to pass the filename to the javascript function and this function returns the format of the file. By using this function you can get that the file is an image (png, jpg, jpeg), pdf, or in any other format.-
Get file extension using file name with replace method in javascript
<script> function getFileExtension(fileName){ var fileExtension; fileExtension = fileName.replace(/^.*\./, ''); return fileExtension; } var fileExt = getFileExtension('filename.jpg'); console.log(fileExt); </script>
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Javascript
- How to get query string value in javascript
- Concat variable with string in javascript
- Remove property from object in javascript
- How to check file is an image in javascript using filename
- How to get the length of a number in JavaScript
- Short-circuits conditionals
- Hide div on click outside of element in javascript/jQuery
- Generate 6 digit random number in javascript
- How to display for slash as a string in javascript HTML
- Remove hostname from URL in javascript
- How to add a property to object with condition in javascript
- How to echo array in Javascript
- Deault order of record in datatable
- Javascript get only 10 characters from string
- Uncaught TypeError: $(...).summernote is not a function
- Check if value exists in array javascript
- How to get data from localstorage in javascript
- Trim the leading and trailing comma from string in Javascript
- JavaScript test() Method
- How to remove duplicate values from array in javascript
- How to make entire Div clickable in javascript
- ReferenceError: $ is not defined
- How to use JavaScript to search for items in a list
- Custom slider js
- Uncaught SyntaxError: Identifier 'CODE' has already been declared