Android的HTML5 FileApi我可以读取SD卡的文件吗? [英] Android HTML5 FileApi can i read file from SD Card?

查看:1829
本文介绍了Android的HTML5 FileApi我可以读取SD卡的文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有网站读取SD卡的Andr​​oid(我知道,这个文件的SD卡存在)某些文件的浏览器工作时的方式?

Is there a way for Website to read certain file from Android SDCard (i know that this file exist on SDCard) while working in browser?

我希望我的网站打开某些视频文件从SD卡(hugeXXX.avi):)

I want my website to open "certain video file" from SDCard (hugeXXX.avi) :)

它甚至有可能?

推荐答案

在HTML5的文件系统的API允许网页打开并仅在沙盒文件系统操作文件。浏览器决定在哪里以及该沙盒文件系统如何存在,并且您的网页无法打出来的沙箱来访问设备的文件系统的实际任意文件。

The HTML5 Filesystem API allows web pages to open and manipulate files only within a sandboxed filesystem. The browser decides where and how this sandboxed filesystem exists, and your webpage cannot break out of the sandbox to access arbitrary files on the device's actual filesystem.

您的能有什么的做的是提供一个文件输入元素(<输入类型=文件> ),允许的用户的指定文件,你的网页的内容然后上传/读取。在这种情况下,用户可以在设备的文件系统内的选择的任何文件,包括安装SD卡。请参阅 HTML5岩石上读取文件教程

What you can do is provide a file input element (<input type=file>) that allows the user to specify a file that your webpage can then upload/read. In that case, the user can select any file within the device's filesystem, including mounted SD cards. See the HTML5 Rocks tutorial on reading files.

所以,不,是没有办法做到precisely你想要什么,出于安全原因。

So, no, there is no way to do precisely what you want, for security reasons.

(当然,除非,网页被托管的设备本身的和有问题的文件上坐在你的网站目录下,然后你可以从服务器通过Ajax调用或类似的加载(也就是说,从设备本身,它承载的网页)进行加载。)

(Unless, of course, the webpage were hosted on the device itself and the file in question sat in your website directory. Then you could load it from the server via an Ajax call or similar (that is, load it from the device itself, which hosts the page).)

这篇关于Android的HTML5 FileApi我可以读取SD卡的文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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