Skip to main content
100%

Gist 7571798

✓ Published0🌍 Public
Aamundo
Last edited Dec 4, 2012
Created on Nov 20, 2013

This example shows a file-reading utility that loads either image or text files into the browser using the HTML5 File API. It creates a FileReader instance and wraps its asynchronous operations in a jQuery Deferred object, returning a promise that resolves with the file’s content. For images, the reader uses `readAsDataURL` to produce a base64-encoded data URL; for all other file types, it uses `readAsText` to retrieve the raw string. The code handles load and error events, rejecting the promise on failure.

AI-generated description

Similar vizzes