使用HTML5标记获取图像的最后修改日期 [英] getting lastmodified date of image using HTML5 tag

查看:113
本文介绍了使用HTML5标记获取图像的最后修改日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用HTML5标签用智能手机(Android,iOS,windows)相机捕捉图像或从图库中选择图像。这是一个离子项目,必须在Apache服务器上使用Web浏览器运行(不在手机上安装应用程序)。

I have tried to use the HTML5 tag to capture image with smartphone (android, iOS, windows) camera or choose image from gallery. It is an ionic project, which has to run with web browser (without installing app on phone) on apache server.

<input id="camera" type="file" accept="image/*" >

现在我需要获取图库图像的最后修改日期以检查所选图像的年龄。

Now I need to get the lastmodified date of gallery image to check the age of the images which is selected.

但我没有找到任何可行的解决方案......任何人都可以帮助我吗?
这将是非常好的......

But I didn't find any working solution... can anyone help me? It would be very nice...

非常感谢!
问候

Thanks so much! Greetings

---编辑---
感谢您的解决方案:

---edited--- Thanks for the solution:

var fileInput = document.getElementById("myFileInput")
var file = fileInput.files[0]
var lastModified = fileInput.files[0].lastModified

但这不适用于iOS ...

But this doesn't work with iOS...

文件对象(文件)的内容...

The content of file object (file) in...

OSX chrome:

OSX chrome:

{"0":{}}

android chrome:

android chrome:

{"0":{}}

safari iPhone:

safari iPhone:

{"0":{},"length":1}

我不知道为什么这个对象没有显示更多属性...因为在chrome上OSX和Android file.lastModified以毫秒显示日期。

I don't know why this object doesn't show more attributes... because on chrome for OSX and Android file.lastModified shows the date in ms.

有没有人可以在这里帮忙?
非常感谢!

is there anybody who can help out here? Thanks so much!

推荐答案

似乎有可能这样:

var fileInput = document.getElementById("myFileInput")
var file = fileInput.files[0]
var lastModified = fileInput.files[0].lastModified

这是一个小提琴:
jsFiddle

这篇关于使用HTML5标记获取图像的最后修改日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆