简体   繁体   中英

Android HTML5 FileApi can i read file from SD Card?

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM