Android HTML5 FileApi can i read file from SD Card?

旧街凉风 提交于 2019-12-11 23:20:58

问题


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?

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

Is it even possible?


回答1:


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.

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.

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

(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).)



来源:https://stackoverflow.com/questions/11145614/android-html5-fileapi-can-i-read-file-from-sd-card

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!