31715

Android HTML5 FileApi can i read file from SD Card?

Question:

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 <strong>website</strong> to open "certain video file" <strong>from SDCard</strong> (hugeXXX.avi) :)

Is it even possible?

Answer1:

The HTML5 <em>Filesystem</em> 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 <em>can</em> do is provide a file input element (<input type=file>) that allows the <em>user</em> 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 <a href="http://www.html5rocks.com/en/tutorials/file/dndfiles/" rel="nofollow">HTML5 Rocks tutorial</a> 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 <em>on the device itself</em> 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).)

Recommend

  • Inter application communication in iphone
  • Using an iframe for sandboxing?
  • How to prevent context menu in an iframe?
  • Flicker when custom drawing on a double buffered TTreeView
  • Testing a python script in a specific version
  • FormFlow define options for string field
  • How to write Delphi ActiveX control which can be used in MS Word/Excel/Powerpoint?
  • jQuery ajax security
  • Problem glTexGen in Open GL ES 2.0
  • CDI: Injecting single instance works, but injecting Instance does not. Why?
  • Can I customize a Jackson ObjectMapper by adding a module?
  • Laravel Impossible to Create Root Directory
  • Use of qualified name in function parameter
  • How to protect the mp3 file from read or copy on Android?
  • PHP: Very simple Encode/Decode string
  • Mapping two workspace folders to the same working directory
  • Calling C function from lua
  • WordPress > setting permalink option via script buggy?
  • Is there a way to dynamically embed PDF Files in a JSP pulled from the file system?
  • How can Delete be both a DDL and a DML statement
  • Eclipse MTJ doesn't see Java ME SDK 3.0 devices
  • blade.php method outputting it's result to the form
  • Do I need to seed any random number generator before using EVP_PKEY_keygen of OpenSSL?
  • JqueryMobile Popup menu is not working
  • Inline R code in YAML for rmarkdown doesn't run
  • How to add git credentials to the build so it would be able to be used within a shell code?
  • Groovy: Unexpected token “:”
  • MVC3 Razor - ListBox pre-select not working
  • How to create a file in java without a extension
  • Reading JSON from a file using C++ REST SDK (Casablanca)
  • Repeat a vertical line on every page in Report Builder / SSRS
  • FB SDK and cURL: Unknown SSL protocol error in connection to graph.facebook.com:443
  • Sony Xperia Z Tablet not found by adb
  • MySQL WHERE-condition in procedure ignored
  • Can I make an Android app that runs a web view in Chrome 39?
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • How do I rollback to a specific git commit
  • Is there a mandatory requirement to switch app.yaml?
  • Busy indicator not showing up in wpf window [duplicate]
  • UserPrincipal.Current returns apppool on IIS