How to get the modified time of a file being uploaded in JavaScript?

前端 未结 3 1896
礼貌的吻别
礼貌的吻别 2020-12-01 17:43

Is there ever a way possible to get the actual creation / modification time of the file being uploaded, using JavaScript?

As for PHP, using filectime() a

3条回答
  •  没有蜡笔的小新
    2020-12-01 17:50

    Perhaps you could use javascript to get the last modified time, then use that in some other javacript to sort on that. This time will be in GMT.

    var xmlhttp = createXMLHTTPObject();
    xmlhttp.open("HEAD", "http://myurl/interesting_image.jpg" ,true);
    xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4) {
        alert("Last modified: "+
         var lastModTimeForInterestingImage = xmlhttp.getResponseHeader("Last-Modified"))
      }
    }
    xmlhttp.send(null);
    

提交回复
热议问题