read files from html `<input type="file">` elements
npm install upload-elementread files from html elements
First write some html with an element:
`` html`
` js
var upload = require('upload-element');
var elem = document.querySelector('#upload')
upload(elem, { type: 'text' }, function (err, files) {
files.forEach(function (file) {
document.bodyinnerHTML += file.target.result;
});
});
`
` js`
var upload = require('upload-element')
Read elem, an or
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, has result property with the string orresult.file
arraybuffer of the file contents
* - file object, has name 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)
With npm do:
```
npm install upload-element
MIT