Capture the date of creation of the file

2

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

POST is done via JavaScript, but I wanted to know how do I know when the source file was created.

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?

    
asked by anonymous 31.01.2017 / 00:33

1 answer

3

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

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

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>
    
31.01.2017 / 00:41