[Asp.net]Uploadify所有配置说明,常见bug问题分析
复制代码
1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Wolfy.UploadifyDemo.Default" %>
2
3 <!DOCTYPE html>
4
5 <html xmlns="https://www.w3.org/1999/xhtml">
6 <head runat="server">
7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
8 <title></title>
9 <%-- 首先引入相关的css,js文件 --%>
10 <link href="Uploadify/css/uploadify.css" rel="stylesheet" />
11 <script src="Uploadify/js/jquery-1.10.2.min.js"></script>
12 <script src="Uploadify/js/uploadify3.2.1/jquery.uploadify.min.js"></script>
13 </head>
14 <body>
15 <form id="form1" runat="server">
16 <p class="pMain">
17 <p id="fileQueue">
18 </p>
19 <input type="file" name="uploadify" id="file_upload" />
20 <p id="haveupfile">
21 </p>
22 <p>
23 <p>
24 <a href="javascript:$('#file_upload').uploadify('cancel','*');">取消上传(将触发onClearQueue事件)</a>
25 </p>
26 <p>
27 <a href="javascript:$('#file_upload').uploadify('destroy')">销毁(将调用Destroy)</a>
28 </p>
29 <p>
30 <a href="javascript:$('#file_upload').uploadify('disable', true);">禁用上传功能</a>
31 </p>
32 <p>
33 <a href="javascript:$('#file_upload').uploadify('disable', false);">启用上传功能</a>
34 </p>
35 <p>uploadify中的方法</p>
36 <p>
37 <a href="javascript:$('#file_upload').uploadify('cancel')">取消队列中第一个文件</a> | <a href="javascript:$('#file_upload').uploadify('cancel', '*')">取消队列中所有文件</a> | <a href="javascript:$('#file_upload').uploadify('upload', '*')">开始上传队列中所有文件</a>
38 </p>
39 <p>
40 <a href="javascript:$('#file_upload').uploadify('destroy')">销毁Uploadify实例</a>
41 </p>
42 <p>
43 <a href="javascript:$('#file_upload').uploadify('disable', true)">禁用选择按钮</a> | <a href="javascript:$('#file_upload').uploadify('disable', false)">启用选择按钮</a>
44 </p>
45 <p>
46 <a href="javascript:changeBtnText()">改变按钮上面的文字</a> | <a href="javascript:returnBtnText();">读取按钮上面的文字</a>
47 </p>
48 <p>
49 <a href="javascript:$('#file_upload').uploadify('upload', '*')">开始上传</a> | <a href="javascript:$('#file_upload').uploadify('stop')">停止上传</a>
50 </p>
51 </p>
52 </p>
53 </form>
54 </body>
55 </html>
56
57 <script type="text/javascript">
58 $(function () {
59 $('#file_upload').uploadify({
60 'auto': false, //选择文件后是否自动上传,默认为true
61 'buttonClass': 'some-class',
62 //'buttonImage': 'Uploadify/icon/btn.png',//选择文件按钮
63 'buttonText': '浏 览',//设置按钮文本
64 //'debug': true,//是否打开调试模式,默认为false
65 'fileSizeLimit': '5000KB',//单个文件大小,0为无限制,可接受KB,MB,GB等单位的字符串值
66 'fileTypeDesc': 'Image Files',//文件描述
67 'fileTypeExts': '*.gif; *.jpg; *.png',//允许上传的文件类型
68 //'formData': { 'someKey': 'someValue', 'someOtherKey': 1 },//传参数
69 //'height': 50,//按钮的高度
70 //'itemTemplate': '<p id="${fileID}" class="uploadify-queue-item">\
71 // <p class="cancel">\
72 // <a href="javascript:$(\'#${instanceID}\').uploadify(\'cancel\', \'${fileID}\')">X</a>\
73 // </p>\
74 // <span class="fileName">${fileName} (${fileSize})</span><span class="data"></span>\
75 // </p>',//队列中的每个项目一个特殊的HTML模板
76 //'method': 'post',//请求方式"get"或者"post",默认为"post"
77 //'multi': false,//是否允许同时选择多个文件,默认为true
78 //'overrideEvents': ['onUploadError'],//不执行某个默认事件如:onUploadError上传失败事件
79 //'preventCaching': false,//是否取消缓存,默认为true没有缓存
80 //'progressData': 'speed',//上传进度条显示,'percentage'or'speed'默认为'percentage'
81 'queueID': 'fileQueue',//队列的ID,一个存放上传文件p的ID
82 //'queueSizeLimit':1,//可同事选择上传文件的数量,默认为999
83 //'removeCompleted': false,//是否移除在队列中上传完成的文件,默认为true
84 //'removeTimeout': 10,//在队列中上传完成延迟多少秒移除,默认为3秒
85 //'requeueErrors': true,//上传失败是否重新上传,默认为false
86 //'successTimeout': 5,//上传成功之后等待响应时间swf成功,默认为30秒
87 'swf': 'Uploadify/js/uploadify3.2.1/uploadify.swf',//FLash文件路径
88 'uploader': '/UploadHander.ashx',//上传文件处理后台页面
89 //'uploadLimit': 1,//允许上传最大文件数,超过onUploadError事件被触发,默认999
90 //'width': 300,//按钮宽度
91 /**********************************************事件***********************************************************************/
92 //'onCancel': function (file) {//取消单个文件上传触发
93 // alert('The file ' + file.name + ' was cancelled.')
94 //},
95 //'onClearQueue': function (queueItemCount) {//取消队列中所用上传文件触发
96 // alert(queueItemCount + ' file(s) were removed from the queue');
97 //},
98 //'onDestroy': function () {//销毁触发
99 // alert('I am getting destroyed!');
100 //},
101 //'onDialogClose': function (queueData) {//关闭窗口时触发
102 // //queueData属性如下
103 // //filesSelected:在浏览文件对话框中选择文件的数量
104 // //filesQueued:添加到队列中文件的数量(即没有返回错误)
105 // //filesReplaced:在队列中替换的文件数
106 // //filesCancelled:文件已被添加到队列中取消数(不更换)
107 // //filesErrored:返回错误的文件数
108 // alert(queueData.filesQueued + ' files were queued of ' + queueData.filesSelected + ' selected files. There are ' + queueData.queueLength + ' total files in the queue.');
109 //},
110 //'onDialogOpen': function () {//打开对话框时触发
111 //},
112 //'onDisable': function () {//禁用上传功能触发
113 // alert('You have disabled Uploadify!');
114 //},
115 //'onEnable': function () {//启用上传功能触发
116 // alert('You can use Uploadify again.');
117 //},
118 'onFallback': function () {//初始化浏览器不兼容触发 也可监视浏览器是否禁用flash播放插件
119 alert('Flash was not detected.');
120 },
121 //'onInit': function (instance) {//初始化时触发
122 // alert('The queue ID is ' + instance.settings.queueID);
123 //},
124 //'onQueueComplete': function (queueData) {//队列中所有文件处理完成触发
125 // //queueData属性如下
126 // //uploadsSuccessful:上传的文件数量已顺利完成
127 // //uploadsErrored:传回错误的上传数量
128 // alert(queueData.uploadsSuccessful + ' files were successfully uploaded.');
129 //},
130 //'onSelect': function (file) {//选择文件时触发
131 // alert('The file ' + file.name + ' was added to the queue.');
132 //},
133 //'onSelectError': function () {//选择文件出现错误时触发,如超出文件大小设置
134 // //返回file
135 // //返回errorCode
136 // //返回errorMsg
137 // //alert(errorCode);
138 // //alert('The file ' + file.name + ' returned an error and was not added to the queue.');
139 //},
140 //'onSWFReady': function () {//当Flash对象加载触发。
141 // alert('The Flash file is ready to go.');
142 //},
143 //'onUploadComplete': function (file) {//当上传完成后是否成功,或返回错误为每个文件触发一次
144 // alert('The file ' + file.name + ' finished processing.');
145 //},
146 //'onUploadError': function (file, errorCode, errorMsg, errorString) {//上传文件失败时触发
147 // alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
148 //},
149 //'onUploadProgress': function (file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) {//上传进度数据
150 // $('#progress').html(totalBytesUploaded + ' bytes uploaded of ' + totalBytesTotal + ' bytes.');
151 //},
152 //'onUploadStart': function (file) {//开始上传触发
153 // alert('Starting to upload ' + file.name);
154 //},
155 //'onUploadSuccess': function (file, data, response) {//上传成功后触发,每个文件都触发
156 // alert('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data);
157 //}
158 });
159 });
160 function changeBtnText() {
161 $('#file_upload').uploadify('settings', 'buttonText', 'BROWSE');
162 }
163
164 function returnBtnText() {
165 alert('The button says ' + $('#file_upload').uploadify('settings', 'buttonText'));
166 }
167 </script>
复制代码