Yes, web pages can read files from the file system in a very restricted way: there must be an <input type="file">
on the page, the user must activate it, and they must select file(s) in some platform specific manner. These restrictions exist for obvious security reasons. A page cannot arbitrarily read a file given a path.
Once the user has selected one or more files, you can read the files
property from the input
element, and get an array of File objects. Instantiate a FileReader
object with the File
, and use one of the methods there to read the file, such as readAsBinaryString()
.
MDN has a pretty good overview of accessing files from web applications. It goes into more detail about handling things like drag and drop.
If you are using this in an AngularJS application, you will probably want to wrap it up in a service.
I did a quick search, I'm sure there are several available FileReader wrappers for Angular available on google, for example, or ng-file-upload.