Solved

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

Posted on 2004-08-18
4
285 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 100 total points
ID: 11830929
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
ID: 11830950
Right, you'd have to use the file system object in ASP or something like that..
0
 

Author Comment

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

Expert Comment

by:Zvonko
ID: 11831303
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

 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
Suggested Courses

630 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