upload-element
read files from html <input type="file">
elements
example
First write some html with an <input type="file">
element:
var upload = ;var elem = document;
methods
var upload =
upload(elem, opts, cb)
Read elem
, an <input type="file">
or <input type="file" multiple>
element.
When the user uploads a file and all the files have been read,
cb(err, results)
fires with an error or the list of files.
results
is an array of objects, each with:
result.target
- target object, hasresult
property with the string or arraybuffer of the file contentsresult.file
- file object, hasname
and other properties
Set opts.type
to control the type of result.target.result
:
'text'
- string of content'url'
- string base64 data url'array'
- arraybuffer of content (default)
install
With npm do:
npm install upload-element
license
MIT