How to get file Information like name, size, type and modified date in JavaScript

Information like, Javascript, URL Parameters

It is good idea to apply client side validation to make form or file validation sudden, Information like Always reach validate file opinion in the back sending to remove taking into consideration if user upload some file, apply client side validation as regards file type, size which in the future happening user to upload definite file on the subject of the order of server, Following are the single descent of code is JavaScript to get sticking to of proclaim, size, type and last modified date of selected files.

Get File Name in JavaScript

var fileName = document.getElementById('file').files[0].name;

Get File Type in JavaScript

var fileType = document.getElementById('file').files[0].type;

Get File Size in JavaScript

var fileSize = document.getElementById('file').files[0].size;

Get File Lst Modified Date in JavaScript

var fileLastModifiedDate = document.getElementById('file').files[0].lastModifiedDate;

Using above take leisure motion you can easily make custom JavaScript take leisure doings-engagement-conflict to obtain every one the file details in array

function getFileInfo(){
    var fileInfo = new array();
        fileInfo['fileName'] = document.getElementById('file').files[0].name;
        fileInfo['fileSize'] = document.getElementById('file').files[0].size;
        fileInfo['fileType'] = document.getElementById('file').files[0].type;
        fileInfo['fileModifiedDate'] = document.getElementById('file').files[0].lastModifiedDate;

Leave a Reply