Link to home
Start Free TrialLog in
Avatar of iemonslice
iemonslice

asked on

Display a file's last modified date on your webpage.

There exists a file C:\whatever\file.txt

How would I obtain the last modified time and date for this file using JavaScript?
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Right, you'd have to use the file system object in ASP or something like that..
Avatar of iemonslice
iemonslice

ASKER

K, can't do this using javascript.
Thank you for trusting me.
Here is a workaround which works only if the file is below the web servers root directory and your server support the lastModified attribute and the browser can access that document attribute:

<html>
<body>
<iframe name="theFile" src="whatever/file.txt" width=0 height=0"></iframe>
<b>File: </b>whatever/file.txt<br>
<b>Date Modified: </b>
<script>
document.write(window.frames.theFile.document.lastModified)
</script>
</body>
</html>

Good luck,
Zvonko