Capture file creation date

Asked

Viewed 201 times

2

I am implementing an FTP file upload tool on the web, I use the input type file.

POST is done via Javascript, but wanted to know how to know the date of creation of the source file.

Ex.: file.exe created in 2016 is this the value I want and not the value that goes in temp is it possible to fetch the date with Javascript after selecting the file? Before using Curl to upload the file?

1 answer

3


The date of creation itself has no way to recover, at least not "natively".

However, it is possible to recover the date of last file modification by using the property lastModifiedDate.

function clickButton(){
  var files = document.getElementById('input-file').files;
  
  for (var i = 0; i < files.length; i++)
    console.log(files[i].lastModifiedDate);
}

document.getElementById('bt-info').addEventListener('click', clickButton);
<input type="file" id="input-file" /> <br>

<button id="bt-info">Informações</button>

  • thanks for the help

Browser other questions tagged

You are not signed in. Login or sign up in order to post.