跨设备照片捕获上传

由于iOS6 Mobile Safari浏览器的用户已经能够通过相机或相册从他们的设备上传图像。

Web开发人员只需编写一个上传脚本绑定文件input标签,如下所示:

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

这将提示iOS用户select图像源(图像文件或相机),然后将图像上传到服务器。 就像在这个图像。

移动Safari iOS图片源提示

这适用于Mobile Safari的iOS,但是我希望在Windows Phone,Android以及iOS iPhone和iPad中具有相同的行为。

每个设备是否有类似的HTML规范?

你可以使用Chris Droukas提供的链接来回答这个问题。

谢谢。

编辑:

我有机会尝试Android 4.2和iOS6上的<input type="file" accept="image/*" capture="camera"> ,并且允许用户拍照(或select一个)提交。

有更多设备的人可以告诉我这是否有效吗?

根据此图表 , HTML Media Capture可在以下移动平台上使用:

iOS Safari :6.0及更高版本

Android浏览器 :3.0以上

Google Chrome :4.0及更高版本

BlackBerry浏览器 :BB10

Opera Mobile(Android和Symbian) :14.0以上

Firefox(Android,MeeGo) :11.0以上

它在Windows Phone上的Internet Explorer中似乎不受支持。 你可以在这里testing不同的设备。

使用PhoneGap :

 <script type="text/javascript" charset="utf-8" src="phonegap-1.1.0.js"></script> <script> function takePicture() { navigator.camera.getPicture( function (uri) { var img = document.getElementById('camera_image'); img.style.visibility = "visible"; img.style.display = "block"; img.src = uri; document.getElementById('camera_status').innerHTML = "Success"; }, function(e) { console.log("Error getting picture: " + e); document.getElementById('camera_status').innerHTML = "Error getting picture."; }, { quality: 50, destinationType: navigator.camera.DestinationType.FILE_URI}); }; </script> <input type="button" onclick="takePicture();" value="Take Picture" /><br/>