Skip to content

基于html5的文件上传工具,支持对文件类型,大小,以及针对图片的尺寸进行校验

Notifications You must be signed in to change notification settings

zhangxu0413/fileUploader_html5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FileUploader

基于html5的文件上传插件

Version: 0.0.1
Author: zhangxu [email protected]

FileUploader~FileUploader

文件上传工具构建类

Kind: inner class of FileUploader

new FileUploader(settings)

Param Type Description
settings Object 初始化参数集

FileUploader~_defaults : Object

默认参数配置

Kind: inner property of FileUploader

FileUploader~_acceptTypeList : enum

文件类型映射

Kind: inner enum of FileUploader

FileUploader~_errorList : enum

错误码映射

Kind: inner enum of FileUploader

FileUploader~init(setting)

上传工具实例化入口

Kind: inner method of FileUploader

Param Type Description
setting Object 初始化参数
setting.Debug String 是否开启调试模式,调试模式会在控制台打印日志
setting.id String 实例id
setting.uploadUrl String 上传路径
setting.picker String | jQuery | Document 指定选择文件的按钮容器,可以是选择器,也可以是dom元素或jquery元素
setting.auto Boolean 读取文件后是否自动开始上传,默认自动上传
setting.responseType String [json
setting.acceptType String [excel
setting.data Object 上传过程中携带的参数
setting.sizeLimit Number 上传文件大小限制,默认不限制 单位是k
setting.widthLimit Number 上传文件的宽度限制,仅在上传文件类型为图片的情况下生效,单位px
setting.heightLimit Number 上传文件的高度限制,仅在上传文件类型为图片的情况下生效,单位px
setting.events Object 上传过程中的事件
setting.events.beforeFileQueued function 在文件被加入读入内存前触发
setting.events.error function 校验出错触发
setting.events.fileQueued function 在文件准备上传时触发
setting.events.uploadStart function 在开始上传时触发
setting.events.uploadAbort function 上传中断时出触发
setting.events.uploadProgress function 上传过程中触发
setting.events.uploadComplete function 上传完成时出触发
setting.events.uploadSuccess function 上传成功时触发
setting.events.uploadError function 出错时触发,上传过程中出错

FileUploader~_createUpLoader()

创建uploader实例

Kind: inner method of FileUploader

FileUploader~reset()

重置上传实例

Kind: inner method of FileUploader

FileUploader~destory()

销毁上传实例

Kind: inner method of FileUploader

FileUploader~upload()

开始上传,仅在auto为false时生效

Kind: inner method of FileUploader

FileUploader~error(code, info)

报错函数

Kind: inner method of FileUploader

Param Type Description
code Number 错误码 详见错误码列表
info String 错误信息

FileUploader~_log(text, [level])

本地日志打印,调试模式开启时在控制台打印日志

Kind: inner method of FileUploader

Param Type Default Description
text String 需要打印的日志内容
[level] Number 0 level 日志级别,选填,默认为0,

FileUploader~_valiate(file, callback)

Kind: inner method of FileUploader
Decription: 验证文件是否符合要求

Param Type Description
file Object
callback function 回调函数

FileUploader~_checkImage(result) ⇒ Boolean

核对图片尺寸

Kind: inner method of FileUploader

Param Type
result Object

FileUploader~_bindEvents()

上传组件事件绑定

Kind: inner method of FileUploader

FileUploader~_fileHander(file)

用fileReader对文件处理

Kind: inner method of FileUploader

Param Type Description
file File 从input上读入的文件

FileUploader~_executeEvents(eventName, file, opts)

手动触发绑定过的事件,类似于trigger

Kind: inner method of FileUploader

Param Type Description
eventName String 事件名称
file Object 当前的文件
opts Object | function 其他数据或回调函数

"beforeFileQueued" (file)

在文件被加入读入内存前触发

Kind: event emitted by FileUploader

Param Type Description
file file 从本地读入的文件

"error" (file, data)

校验出错触发

Kind: event emitted by FileUploader

Param Type Description
file file 从本地读入的文件
data Object 错误对象
data.code number 错误码,member:_errorList
data.msg string 错误文案

"fileQueued" (file)

在文件准备上传时触发

Kind: event emitted by FileUploader

Param Type Description
file file 从本地读入的文件

"uploadStart" (file)

在开始上传时触发

Kind: event emitted by FileUploader

Param Type Description
file file 从本地读入的文件

"uploadAbort" (file)

上传中断时出触发

Kind: event emitted by FileUploader

Param Type Description
file file 从本地读入的文件

"uploadProgress" (file)

上传过程中触发

Kind: event emitted by FileUploader

Param Type Description
file file 从本地读入的文件

"uploadComplete" (file)

上传完成时出触发

Kind: event emitted by FileUploader

Param Type Description
file file 从本地读入的文件

"uploadSuccess" (file, res)

上传成功时触发

Kind: event emitted by FileUploader

Param Type Description
file file 从本地读入的文件
res Object | String 服务器返回的内容

"uploadError" (file)

上传出错时触发,不包括校验时出错

Kind: event emitted by FileUploader

Param Type Description
file file 从本地读入的文件

About

基于html5的文件上传工具,支持对文件类型,大小,以及针对图片的尺寸进行校验

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published