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 ...
随机推荐
- C 常用的输入输出 栈 哈希 文件写读 实现 字符串处理
#include "stdafx.h"#include <stdio.h>#include <string.h>#include <stdlib.h& ...
- 高德地图搜索提示获取信息回传activity刷新ui(二)
应用场景: 在主activity中点击进入到另一个activity搜索提示,获取经纬度,点确定返回到主activity,虽然说需求很奇葩,但是遇到了没办法.. 主要包含两部分,搜索提示+activit ...
- js或者cs代码拼接html
一:使用到的jQuery 文档操作方法 html() 设置或返回匹配的元素集合中的 HTML 内容. append() 向匹配元素集合中的每个元素结尾插入由参数指定的内容. empty() 删除匹配的 ...
- 逆转字符串leetcode
public class Solution { public String reverseWords(String s) { String ans=reverse(s); String s2[]=an ...
- leetcode 合并区间
使用最简单的排序方法: /** * Definition for an interval. * public class Interval { * int start; * int end; * In ...
- C# 使用Nlog记录日志到数据库 使用LogEventInfo类获取,命名空间名称、类名、方法名
原文地址:http://dotnet.9sssd.com/csbase/art/793 [摘要]Nlog是一个很不错的.NET日志记录组件,它可以将日志输出到控件台,保存到文本,也可以很方便的记录到数 ...
- GPG error: the public key is not available
GPG error: The following signatures couldn't be verified because the public key is not available I h ...
- centos6.5建立cloudera-cdh4.6本地源
1.准备: centos6.5系统,root用户 2.安装所需包: sudo yum install yum-utils createrepo 3.下载cdh4.6的repo: ...
- Cows - POJ 3348(凸包求面积)
题目大意:利用n棵树当木桩修建牛圈,知道每头牛需要50平的生存空间,求最多能放养多少头牛. 分析:赤裸裸的求凸包然后计算凸包的面积. 代码如下: --------------------------- ...
- Erasing Edges - SGU 136(构造多边形)
题目大意:已知一个多边形上的每条边的中点,还原出来一个多边形. 分析:因为偶数是不固定的,所以可以为任意起点,奇数只有一个,可以所有中点加减算出来第一个点,然后就是简单的向量计算点的位置了...... ...
