fread is a tiny javascript library that allows you to display uploaded files via the FileReader API (currently only CSV and Image files). It has no external dependencies.
Read more documentation and see examples here
- in : file input selector
- out : output table selector
- before : called before table is rendered
- after : called after table is rendered, receives an argument representing each row
<input type="file" id="files" name="files[]" multiple />
<table id="list" class="table table-bordered table-striped">
<thead></thead>
<tbody></tbody>
</table>
// use default writer
var fread = new fread({
in: '#files',
out: '#list'
before: function(evt){
// perform some action before render
},
after: function(headers, rows){
// perform some action with rows array
}
});
// use a custom writer
var fread = new fread({
in: '#file-input',
writer: function(headers, rows){
// write data to the page
}
});
See examples/index.html or the live example
bower install fread
or Download and include lib/fread.js in your page