Uploadify 笔记分享 -- 2014年10月18日
最近要做一个项目,有个部分需要用到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日的更多相关文章
- 系列文章:老项目的#iPhone6与iPhone6Plus适配#(持续更新中,更新日期2014年10月12日 星期日 )
本文永久地址为http://www.cnblogs.com/ChenYilong/p/4020399.html ,转载请注明出处. ********************************** ...
- 2016年10月18日 星期二 --出埃及记 Exodus 19:2
2016年10月18日 星期二 --出埃及记 Exodus 19:2 After they set out from Rephidim, they entered the Desert of Sina ...
- 20155305《信息安全系统设计基础》10月18日课堂 fork,exic,wait
20155305<信息安全系统设计基础>10月18日课堂 fork,exic,wait fork()函数 1.fork函数作用 一般来讲, 我们编写1个普通的c程序, 运行这个程序直到程序 ...
- 北京Uber优步司机奖励政策(10月12日~10月18日)
用户组:优步北京人民优步A组(适用于10月12日-10月18日) 滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万 ...
- 终端、mac等小技巧——2019年10月18日
1.新建finder窗口 cmd+N 2.查看文件夹结构 brew install tree tree命令行参数(只实用与安装了tree命令行工具): -a 显示所有文件和目录. -A 使用ASNI绘 ...
- 用SQL语句创建四个表并完成相关题目-10月18日更新
1. 查询Student表中的所有记录的Sname.Ssex和Class列. 2. 查询教师所有的单位即不重复的Depart列. 3. 查询Student表的所有记录. 4. 查询Score表中成绩在 ...
- SE 2014年4月18日
实验需求: R1 R2 R3用环回口建立IBGP对等体(使用对等体组),AS号为100 R4 R5 R6用环回口建立IBGP对等体(使用对等体组),AS号为 ...
- 国庆第三天2014年10月3日10:21:39,Nutz,WebCollector,jsoup
(1)做得好,做得快,只能选择一样. (2)时间过得很快,你没法在假期的一天里完成更多的计划.假期全部由自己支配,相对长一点的睡眠,新加入的娱乐(视频或者游戏),你不比在工作中更有效率. (3)每天练 ...
- 2014年10月30日-----SQL的基础知识
数据库的概念 结构化查询语言:structured query language 简称:SQL 数据库管理系统:database management system 简称:DBMS 数据库管理员:da ...
随机推荐
- Condition-线程通信更高效的方式
接近一周没更新<Java线程>专栏了,主要是这周工作上比较忙,生活上也比较忙,呵呵,进入正题,上一篇讲述了并发包下的Lock,Lock可以更好的解决线程同步问题,使之更面向对象,并且Rea ...
- 【HDOJ】3549 Flow Problem
网络流基础题目,Edmonds_Karp可解. /* 3549 */ #include <iostream> #include <string> #include <ma ...
- 【HDOJ】3584 Cube
三位树状数组. /* 3584 */ #include <iostream> #include <string> #include <map> #include & ...
- 使用Redis作为消息队列服务场景应用案例
一.消息队列场景简介 "消息"是在两台计算机间传送的数据单位.消息可以非常简单,例如只包含文本字符串:也可以更复杂,可能包含嵌入对象.消息被发送到队列中,"消息队列&qu ...
- lazyman学习
1.安装: gem install lazyman 2.建立工程: cd到工程目录下 lazyman new 工程名 3.打开调试命令 lazyman c lazyman调用selenium-webd ...
- .Net remoting 的文件传输
http://www.codeproject.com/Articles/14100/Dot-Net-Remoting-Handling-Remote-Events-using-Dele
- android进程间通信:使用AIDL
android 的binder其实是基于 openbinder实现的,openbinder的地址:http://www.angryredplanet.com/~hackbod/openbinder/d ...
- mvn archetyoe:generate -DarchetypeCatalog=internal
可以使用 $mvn archetype:generate -DarchetypeCatalog=internal archetypeCatalog表示插件使用的archetype元数据,默认值为rem ...
- calltree查看工程代码中的函数调用关系
http://blog.csdn.net/elitemouse/article/details/41680113 http://www.tinylab.org/callgraph-draw-the-c ...
- linux进程调度之 FIFO 和 RR 调度策略---SYSTEMTAP
http://blog.chinaunix.net/uid-24774106-id-3379478.html http://blog.chinaunix.net/uid-24774106-id-337 ...