admin管理员组文章数量:1291299
I need to find out the file creation date and file last modified date while uploading the xls file, I have to do some calculation on this 2 dates.
By using below code I can easily get file last modified date.
$('#userfile').bind('change', function() {
//this.files[0].size gets the size of your file.
alert((this.files[0].lastModifiedDate));
alert((this.files[0].DateCreated));
$file_full_path =this.files[0].mozFullPath;
alert(alert);
});
I am not able to find out the the file creation date. can anybody please help me.
I have also tried it via php but it is not possible via php because php doesn't send this information to server.
Please tell me is there any way to get this information. Thanks.
I need to find out the file creation date and file last modified date while uploading the xls file, I have to do some calculation on this 2 dates.
By using below code I can easily get file last modified date.
$('#userfile').bind('change', function() {
//this.files[0].size gets the size of your file.
alert((this.files[0].lastModifiedDate));
alert((this.files[0].DateCreated));
$file_full_path =this.files[0].mozFullPath;
alert(alert);
});
I am not able to find out the the file creation date. can anybody please help me.
I have also tried it via php but it is not possible via php because php doesn't send this information to server.
Please tell me is there any way to get this information. Thanks.
Share Improve this question asked Jan 6, 2015 at 14:07 Anant WaykarAnant Waykar 6822 gold badges8 silver badges19 bronze badges 02 Answers
Reset to default 3You can not get the creation date. Only the last modified date is available in file properties.
source: http://forum.jquery./topic/jquery-file-creation-date-before-upload
For PHP there is a thread here that provides answer: PHP: how can I get file creation date?
It seems unlike the lastModified
property, there is no HTML DOM dateCreated
property. So if JS needs to access the creation date of a document, it has to access it via the metadata of the file for which it should have access to the file system.
JS not having access to the file system is a security feature in the browsers. But, in-case if someone is wanting to know how to get the creation date for the document for JS as in NodeJS (which of-course has the access to the file-system), then they can use the file system
module to get the birthtime
property as follows:
const fs = require('fs');
var file = "location-of-my-file";
var dateCreated = fs.statSync(file).birthtime;
console.log("This File was born on:" + dateCreated);
NOTE : The above is only if you are programming a NodeJS app. This will not run on a normal web-browser, and will instead give the following console error : Uncaught ReferenceError: require is not defined
.
本文标签: phpHow to get file creation date on browser using javascript or jqueryStack Overflow
版权声明:本文标题:php - How to get file creation date on browser using javascript or jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741505923a2382318.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论