HTML5的FileReader接口封装 – FileReader.js

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) {

    	}
    }
};

项目主页:http://www.open-open.com/lib/view/home/1338651006609

扩展阅读:

html5将图片转换base64进行上传、解决微信内置浏览器上传图片问题
HTML5学习之FileReader接口
HTML5的FileReader接口封装 – FileReader.js

发表评论

邮箱地址不会被公开。 必填项已用*标注