问题
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