Solved

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

Posted on 2004-08-18
4
271 Views
Last Modified: 2013-12-16
There exists a file C:\whatever\file.txt

How would I obtain the last modified time and date for this file using JavaScript?
0
Comment
Question by:iemonslice
  • 2
4 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 100 total points
Comment Utility
If the file exist on web server and your script is running in browser, then you have no chance accessing some files attributes.
0
 
LVL 19

Expert Comment

by:peh803
Comment Utility
Right, you'd have to use the file system object in ASP or something like that..
0
 

Author Comment

by:iemonslice
Comment Utility
K, can't do this using javascript.
0
 
LVL 63

Expert Comment

by:Zvonko
Comment Utility
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

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now