拍摄的图像与HTML5的移动设备 [英] captured images with HTML5 for mobile devices

查看:187
本文介绍了拍摄的图像与HTML5的移动设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的HTML 5 <输入类型=文件接受=图像/ *;捕获=镜头/> 文件的Web移动元素
拍照它工作正常,但我怎么能处理file.value将其发送到Web服务或数据库?
这里是演示的移动设备演示链接

这是我的code,但不工作
我不能让文件上传值

 < HTML和GT;
<脚本>
功能getPhoto()
{
警报('2');
VAR FU1 =的document.getElementById(MYFILE)值。
警报(你选择了+ FU1);
}
< / SCRIPT>
<身体GT;
<形式为GT;
<输入类型=文件名称=MYFILE接受=图像/ *;捕捉摄像头=/>
<输入类型=提交/>
<输入类型=按钮值=获取照片路径的onclick =getPhoto()>
< /表及GT;
< /身体GT;
< / HTML>


解决方案

您需要使用文件API:的 http://www.w3.org/TR/FileAPI/

下面是html5rocks.com一个很好的教程: HTTP://www.html5rocks .COM / EN /教程/文件/ dndfiles /

试着做这样的事情。

HTML

 <输入类型=文件ID =MYFILENAME =MYFILE接受=图像/ *;捕捉摄像头=/>

JS

 函数handleFileSelect(EVT){
    var中的文件= evt.target.files; //文件列表对象,文件,[0]是你的文件
}的document.getElementById('文件')的addEventListener('变',handleFileSelect,假的)。

如果你需要阅读JS文件,那么你需要使用的FileReader API。

i am using html 5 <input type="file" accept="image/*;capture=camera"/> file element for web mobile to take photo it works fine but how can i handle file.value to send it to web service or database? here is demo for mobile devices Demo link

here is my code but does not work i can not get file upload value

   <html>
<script>
function getPhoto()
{
alert('2');
var fu1 = document.getElementById("myfile").value;
alert("You selected " + fu1);
}
</script>
<body>
<form>
<input type="file" name="myfile" accept="image/*;capture=camera"/>
<input type="submit"/>
<input type="button" value="get Photo path" onclick="getPhoto()">
</form>
</body>
</html>

解决方案

You need to use the File API: http://www.w3.org/TR/FileAPI/

Here is a nice tutorial from html5rocks.com: http://www.html5rocks.com/en/tutorials/file/dndfiles/

Try doing something like this

HTML

<input type="file" id="myfile" name="myfile" accept="image/*;capture=camera"/>

JS

function handleFileSelect(evt) {
    var files = evt.target.files; // FileList object, files[0] is your file
}

document.getElementById('file').addEventListener('change', handleFileSelect, false);

If you need to read the file in JS, then you need to use the FileReader API.

这篇关于拍摄的图像与HTML5的移动设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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