最近要做一个项目,有个部分需要用到Uploadify,以前用过,但不是很懂,找了无数遍的中文文档,发现好多都是以前的,都不能用,一时间索性自己写了个笔记,随用随查

<form>

<input id="file_upload" name="file_upload" type="file" multiple="true">

<div id="fileQueue"></div>

</form>

<input type="image" src="uploadify/img/upload.jpg" onclick="$('#file_upload').uploadify('upload', '*');" />

<input type="image" src="uploadify/img/cancel.jpg" onclick="$('#file_upload').uploadify('cancel', '*');" />

<script type="text/javascript">

$(function() {

$('#file_upload').uploadify({

'swf': 'uploadify/uploadify.swf',

flash地址              必须

'uploader': 'uploadify.php',

上传的后台地址       必须

'buttonImage': 'uploadify/img/add.jpg',

上传按钮的替换图片

'buttonClass': 'my-uploadify-button',

按钮样式

'width': 102,

按钮宽度

'height'   : 50,

按钮高度

'auto': false,

是否自动上传

'queueID':'fileQueue'

显示的上传内容所在的DIV 的ID

'buttonText': '上传文件',

上传按钮的显示文本

'fileSizeLimit' : '100KB',

限制文件大小     0为不限制

'fileTypeDesc' : 'Any old file you want...',

文件类型下拉框

'fileTypeExts' : '*.gif; *.jpg; *.png',

上传文件的类型

'formData'      : {'someKey' : 'someValue', 'someOtherKey' : 1}

向后台发送Json数据

'multi'    : false,

false为单个上传  true多文件上传

'queueSizeLimit' : 5,

最多同时上传5个

'removeTimeout' : 10,

上传完成后  10秒钟从队列中移除

'requeueErrors': true

如果上传错误 将重新上传

'successTimeout' : 5,

等待服务器响应时,超过5秒  假设上传成功

'onCancel' : function(file) {

alert('The file ' + file.name + ' was cancelled.');

}

从队列中删除一个文件时触发

'onClearQueue' : function(queueItemCount) {

alert(queueItemCount + ' file(s) were removed from the queue');

}

取消上传时触发

'onDialogClose'  : function(queueData) {

alert(queueData.filesQueued + ' files were queued of ' + queueData.filesSelected + ' selected files. There are ' + queueData.queueLength + ' total files in the queue.');

}

当选择文件窗口关闭时触发

'onDialogOpen' : function() {

$('#message_box').html('The file dialog box was opened...');

}

当选择文件窗口打开时触发

<input type="file" name="file_upload" id="file_upload" />

<a href="javascript:$('#file_upload').uploadify('disable', true);">Disable Uploadify</a>

'onDisable' : function() {

alert('You have disabled Uploadify!');

}

使上传按钮失效,失效触发onDisable

<input type="file" name="file_upload" id="file_upload" />

<a href="javascript:$('#file_upload').uploadify('disable', false);">Enable Uploadify</a>

'onEnable' : function() {

alert('You can use Uploadify again.');

}

使上传按钮生效,生效触发onEnable

'onFallback' : function() {

alert('Flash was not detected.');

}

引发了在初始化期间如果没有检测到一个兼容的版本的Flash浏览器。

'onInit'   : function(instance) {

alert('The queue ID is ' + instance.settings.queueID);

}

Uploadify初始化完成时

'onQueueComplete' : function(queueData) {

alert(queueData.uploadsSuccessful + ' files were successfully uploaded.');

}

上传成功时触发

uploadsSuccessful

成功地完成了上传的数量

uploadsErrored

上传的数量返回一个错误

'onSelect' : function(file) {

alert('The file ' + file.name + ' was added to the queue.');

}

选中文件  单击保存之后触发

如果选中多个文件会多次触发

'onSelectError' : function() {

alert('The file ' + file.name + ' returned an error and was not added to the queue.');

}

返回的错误代码。 可以使用以下常量在确定错误代码:

QUEUE_LIMIT_EXCEEDED -文件数量选择将队列的大小通过设置的限制。

FILE_EXCEEDS_SIZE_LIMIT——文件的大小超过了设定的限制。

ZERO_BYTE_FILE——文件没有大小。

INVALID_FILETYPE——文件类型不匹配的文件类型的限制。

'onUploadError' : function(file, errorCode, errorMsg, errorString) {

alert('The file ' + file.name + ' could not be uploaded: ' + errorString);

}

上传错误时触发

file

上传的文件对象

errorCode

返回的错误代码

errorMsg

返回的错误消息

errorString

人类可读的错误消息包含所有的细节错误

<div id="progress"></div>

'onUploadProgress' : function(file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) {

$('#progress').html(totalBytesUploaded + ' bytes uploaded of ' + totalBytesTotal + ' bytes.');

}

file

上传的文件对象

bytesUploaded

已经上传的字节数 单个文件

bytesTotal

文件的字节总数   单个文件   totalBytesUploaded

已经上传的字节数   全部文件

totalBytesTotal

文件的总字节数    全部文件

'onUploadStart' : function(file) {

alert('Starting to upload ' + file.name);

}

即将上传的对象

'onUploadSuccess' : function(file, data, response) {

alert('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data);

}

file
 成功上传文件对象

data
 服务器端脚本返回的数据(

response

到底上传成功了没有如果成功为true

});

});

</script>

Uploadify 笔记分享 -- 2014年10月18日的更多相关文章

  1. 系列文章:老项目的#iPhone6与iPhone6Plus适配#(持续更新中,更新日期2014年10月12日 星期日 )

    本文永久地址为http://www.cnblogs.com/ChenYilong/p/4020399.html ,转载请注明出处. ********************************** ...

  2. 2016年10月18日 星期二 --出埃及记 Exodus 19:2

    2016年10月18日 星期二 --出埃及记 Exodus 19:2 After they set out from Rephidim, they entered the Desert of Sina ...

  3. 20155305《信息安全系统设计基础》10月18日课堂 fork,exic,wait

    20155305<信息安全系统设计基础>10月18日课堂 fork,exic,wait fork()函数 1.fork函数作用 一般来讲, 我们编写1个普通的c程序, 运行这个程序直到程序 ...

  4. 北京Uber优步司机奖励政策(10月12日~10月18日)

    用户组:优步北京人民优步A组(适用于10月12日-10月18日) 滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万 ...

  5. 终端、mac等小技巧——2019年10月18日

    1.新建finder窗口 cmd+N 2.查看文件夹结构 brew install tree tree命令行参数(只实用与安装了tree命令行工具): -a 显示所有文件和目录. -A 使用ASNI绘 ...

  6. 用SQL语句创建四个表并完成相关题目-10月18日更新

    1. 查询Student表中的所有记录的Sname.Ssex和Class列. 2. 查询教师所有的单位即不重复的Depart列. 3. 查询Student表的所有记录. 4. 查询Score表中成绩在 ...

  7. SE 2014年4月18日

    实验需求:   R1 R2 R3用环回口建立IBGP对等体(使用对等体组),AS号为100                     R4 R5 R6用环回口建立IBGP对等体(使用对等体组),AS号为 ...

  8. 国庆第三天2014年10月3日10:21:39,Nutz,WebCollector,jsoup

    (1)做得好,做得快,只能选择一样. (2)时间过得很快,你没法在假期的一天里完成更多的计划.假期全部由自己支配,相对长一点的睡眠,新加入的娱乐(视频或者游戏),你不比在工作中更有效率. (3)每天练 ...

  9. 2014年10月30日-----SQL的基础知识

    数据库的概念 结构化查询语言:structured query language 简称:SQL 数据库管理系统:database management system 简称:DBMS 数据库管理员:da ...

随机推荐

  1. 14.8.1 Creating InnoDB Tables 创建InnoDB 表

    14.8.1 Creating InnoDB Tables 创建InnoDB 表 创建一个InnoDB表,使用CREATE TABLE 语句,你不需要指定ENGINE=InnoDB 子句 如果Inno ...

  2. WordPress Event Easy Calendar插件多个跨站请求伪造漏洞

    漏洞名称: WordPress Event Easy Calendar插件多个跨站请求伪造漏洞 CNNVD编号: CNNVD-201309-083 发布时间: 2013-09-11 更新时间: 201 ...

  3. HDOJ1020 Encoding

    Problem Description Given a string containing only 'A' - 'Z', we could encode it using the following ...

  4. 炮兵阵地 - POJ 1185(状态压缩)

    分析:先枚举出来所有的合法状态(当N=10的时候合法状态最多也就60种),用当前状态匹配上一行和上上一行的状态去匹配,看是否可以.....复杂度100*60*60*60,也可以接受. 代码如下: == ...

  5. 深度学习Matlab DeepLearningToolBox 工具包最常见错误解决办法\

    deeplearningtoolbox  下载链接github : https://github.com/rasmusbergpalm/DeepLearnToolbox,只需要解压到matlab当前工 ...

  6. Newtonsoft.Json 与 DataTable的相互转换

    1.这里下载:http://www.newtonsoft.com/products/json/ 安装:    解压下载文件,得到Newtonsoft.Json.dll    在项目中添加引用 2.引入 ...

  7. hdu 4742 Pinball Game 3D 分治+树状数组

    离散化x然后用树状数组解决,排序y然后分治解决,z在分治的时候排序解决. 具体:先对y排序,solve(l,r)分成solve(l,mid),solve(mid+1,r), 然后因为是按照y排序,所以 ...

  8. otg线是什么,otg线和数据线的区别介绍

    OTG是什么? OTG主要应用于各种不同的设备或移动设备间的联接,进行数据交换.USB技术的发展,使得PC和周边设备能够通过简单方式.适度的制造成本将各种数 据传输速度的设备连接在一起.上述我们的应用 ...

  9. etrace 跟踪 nginx之HTTP请求流程

    curl 127.0.0.1 | | | \--ngx_epoll_process_events | | | | \--ngx_time_update | | | | | \--ngx_gmtime ...

  10. Linux之TCPIP内核参数优化

    /proc/sys/net目录 所有的TCP/IP参数都位于/proc/sys/net目录下(请注意,对/proc/sys/net目录下内容的修改都是临时的,任何修改在系统重启后都会丢失),例如下面这 ...