Is it possible to retrieve the last modified date of a file using Javascript?

前端 未结 5 1852
慢半拍i
慢半拍i 2020-12-08 16:10

I have a set of links on a web page that link to PDF forms and .doc forms. These files are not stored in a database, simply stored as they are, locally on the server. Is i

5条回答
  •  情话喂你
    2020-12-08 16:58

    File.lastModified

    You can use the File.lastModified property to obtain the last modified date of a file as the number of milliseconds since the Unix epoch.

    Example:

    const file = document.getElementById('input').files[0];
    const lastModifiedDate = new Date(file.lastModified);
    
    console.log(`Last Modified Date: ${lastModifiedDate}`);
    

提交回复
热议问题