Retrieving file attributes using Javascript.
Hi there,
Could anyone please suggest a snippet of Javascript code to retrieve the date/time created from a file residing on the web server?
Cheers,
Alex.
Alex
May 28,
Leandro Ardissone
July 30,
i read your question today,
so here my (late) suggestion:
xmlhttp.open("HEAD", "/correctpath/filename",true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
var heads = xmlhttp.getAllResponseHeaders();
heads = heads.split("\n");
for(var a in heads){
var p = document.createElement("DIV");
p.innerHTML = heads[a];
document.body.appendChild(p);
}
}
}
one of the headers is Last-modified
but you get nothing if the file is not correct.
you can specificly get one header
xmlhttp.getResponseHeader("Last-Modified")
but i only tested the first one.
Andres Obrero [Winterthur]
July 30,