FileReader.js 封装了 HTML5 的 FileReader interface ,使用上更加简单。
浏览器支持:
Internet Explorer: 10+
Firefox: 10+
Chrome: 13+
Opera: 12+
Safari: partial
var opts = {
dragClass: "drag",
accept: false,
readAsMap: {
'image/*': 'DataURL',
'text/*' : 'Text'
},
readAsDefault: 'BinaryString',
on: {,
beforestart: function(e, file) {
// return false if you want to skip this file
},
loadstart: function(e, file) {
// Native ProgressEvent
},
progress: function(e, file) {
// Native ProgressEvent
},
load: function(e, file) {
// Native ProgressEvent
},
error: function(e, file) {
// Native ProgressEvent
},
loadend: function(e, file) {
// Native ProgressEvent
},
abort: function(e, file) {
// Native ProgressEvent
},
skip: function(e, file) {
// Called when a file is skipped. This happens when:
// 1) A file doesn't match the accept option
// 2) false is returned in the beforestart callback
},
groupstart: function(group) {
},
groupend: function(group) {
}
}
};
扩展阅读: