O'Reilly logo

HTML5 Data and Services Cookbook by Mite Mitreski, Gorgi Kosev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reading data from files

We have already used file input to read some of the data, but never went into details about file reading and the objects that are available to us. In this recipe, we will create a simple file reader using input file that will act as a mini demonstration of some of the options provided in the File API: Directories and System, http://www.w3.org/TR/file-system-api/.

How to do it...

We will create an HTML file containing a file input control and a progress output for the state of the upload:

  1. We create the controls and a few output placeholders:
    <body> <p> <progress id="progress" value="0" max="100"></progress> <output id="percent" for="progress">0</output> </p> <p> <div id="fileInfo"></div> </p> <input type="file" id="file" value="Choose ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required