uploadify 控件无法回调函数?
直接上代码,可执行后台上传代码,但上传完成后不执行回调函数?onComplete?求解啊!<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="zh-cn" xml:lang="zh-cn" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<title></title>
<link href="../../Content/css/protal/upload_list.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../../Content/css/protal/manage_public.css" />
<link rel="stylesheet" type="text/css" href="../../Content/css/protal/north.css" />
<link rel="stylesheet" type="text/css" href="../../Content/css/protal/south.css" />
<link rel="stylesheet" type="text/css" href="../../Content/css/protal/friends_link.css" />
<link rel="stylesheet" type="text/css" href="../../Content/css/protal/function_public.css" />
<link rel="stylesheet" type="text/css" href="../../Content/css/protal/protal_public.css" />
<link href="../../Content/Upload/uploadify.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../../Content/css/protal/wbox-min.css" />
<script type="text/javascript" src="../../Scripts/jquery-1.6.2.min.js"></script>
<script src="../../Content/Upload/jquery.uploadify.v2.1.0.js" type="text/javascript"></script>
<script src="../../Content/Upload/swfobject.js" type="text/javascript"></script>
<script src="../../Scripts/wbox.js" type="text/javascript"></script>>
<script type="text/javascript">
//选择一个附件
function select(event, queueID, fileObj) {
var name = fileObj.name.split('.');
var ul = document.getElementById("divfileinfo").getElementsByTagName("ul")[0];
var li = document.createElement("li");
li.setAttribute("class", "upload_file_info");
li.setAttribute("id", queueID);
var div = "";
div = " <div class=\"upload_file_info_title blue\"> 填写文档信息</div><div class=\"upload_div_list\">" + "<div class=\"upload_file_info_name\">" + "<b class=\"red\">*</b><span>标题:</span><input name=\"tit" + queueID + "\" class=\"select_long\" value=\"" + name[0] + "\" /></div><div class=\"upload_file_info_text\">简介:<textarea name=\"tat" + queueID + "\"></textarea></div></div><input type=\"hidden\" name=\"Size" + queueID + "\" value=\"" + fileObj.size + "\" /> <input type=\"hidden\" name=\"Ext" + queueID + "\" value=\"." + name[1] + "\" /> <input type=\"hidden\" name=\"FOLDER" + queueID + "\" value=\"\" /> ";
li.innerHTML = div;
ul.appendChild(li);
}
//取消一个附件
function CancelUpload(event, queueId, fileObj, data) {
var li = document.getElementById(queueId);
document.getElementById("divfileinfo").getElementsByTagName("ul")[0].removeChild(li);
}
//验证上传
function fun(event, queueID, fileObj, response, data) {
alert("上传完一个!");
}
//上传文件
function FileUpload() {
jQuery("#myfile").uploadifyUpload();
}
//提交表单
function FormSubmit(event, queueID, fileObj, response, data) {
alert("全部上传完毕!");
jQuery("#myfileup").submit();
}
jQuery(function () {
//上传附件
jQuery('#myfile').uploadify({
'uploader': '../../Content/Upload/uploadify.swf', //浏览按钮swf
'script': '/MyFileUpLoader/FiledUpload.aspx', //调用方法
'cancelImg': '../../Content/Upload/cancel.png', //取消图片
'buttonImg': '../../Content/images/protal/button4.png',
'fileExt': '*.*', //过滤类型-可以上传所有
'fileDesc': '*.*', //提示信息
'sizeLimit': 1024 * 1024 * 50, //50M
'multi': true, //是否批量
'onSelect':select,
'onCancel':CancelUpload,
'onAllComplete':FormSubmit,
'height': 21,
'width': 81,
'onComplete': fun
});
});
</script>
</head>
<body>
<div class="button_left">
<input type="file" id="myfile" name="myfile" /></div>
<div class="button_right"></div>
<div class="button_div">
<button class="button_upload" onclick="FileUpload()">
</button>
or<a href="#">取消</a>
</div>
</form>
</body>
</html>
---------------------------------------------------------------------------------------------
分割线
---------------------------------------------------------------------------------------------
后台上传
[AccessibleThrough(Verb.Post)]
public void FiledUpload()
{
CancelView();
string UPSavefileName = "";
string UPfileName = "";
try
{
if (Request.Files.Count != 0)
{
HttpPostedFile fileData = HttpContext.Current.Request.Files[0];
//设置文件名+获取文件扩展名
UPSavefileName = DateTime.Now.ToString("yyyyMMddHHmmssfffffff") + Path.GetExtension(fileData.FileName);
UPfileName = fileData.FileName;
//上传服务器路径
string filePath = “路径”;
UPSavefileName = filePath + UPSavefileName;
//上传服务器
fileData.SaveAs(UPSavefileName);
}
}
catch
{
Response.Write("N");
}
}
--------------------编程问答-------------------- 围观学习 --------------------编程问答-------------------- ie8里面是可以执行的,ie6里面无法执行回调函数,ie8里面如果不执行的话可能是程序写的不对。
我的帖子是:http://topic.csdn.net/u/20111228/14/df215aa7-c037-4a05-b4f9-d8a233cccbeb.html --------------------编程问答-------------------- 你的事件呢??放一个alert 弹一下 看看执行没 不可能的 我最近一直研究这个插件 --------------------编程问答-------------------- 你的事件没有写完整吧 少了{} --------------------编程问答-------------------- 个人感觉,这个插件设计还不够人性化 --------------------编程问答--------------------
我确认没有JS错误。 --------------------编程问答--------------------
没有啊。 --------------------编程问答-------------------- 问题已解决。 --------------------编程问答--------------------
分呢- - --------------------编程问答-------------------- 我也遇到同样的问题,老是没有返回值,我debug时是在初始化页面时执行的').uploadify({方法。根本无法dubug,求解!!!!!!!!!!
代码:后台返回的
Map rlt = new HashMap();
response.setCharacterEncoding("UTF-8");
response.setContentType("application/vnd.ms-excel");
.......
......
rlt.put("result", result);
File file=new File(myfile);
file.delete();
} catch (Exception e) {
log.debug(e.getMessage());
rlt.put("error", "ERROR");
}
Gson gson = new Gson();
out.write(gson.toJson(rlt));
return null;
}
页面:
$(document).ready(
function() {
$('#companyImportFile').uploadify({
'buttonImg' : '${ctx }/js/uploadlib/button_imp01.gif',
//'buttonText' : '选择',
'fileDataName' : 'imgFile',
'wmode' : 'transparent',
'fileExt' : '*.xls',
'sizeLimit':2097152,
'fileDesc' : '*.xls',
'uploader' : '${ctx }/js/uploadlib/uploadify.swf',
'script' : '${ctx}//util/common/importCoupon.do',
'cancelImg' : '${ctx }/js/uploadlib/cancel.png',
'folder' : '/company',
'auto' : true,
// 'removeCompleted' : true,
'onComplete' : function(event, ID, fileObj,
response, data) {
alert(2);
var result = eval(response);
alert(result.message);
response = JSON.parse(unescape(response));
if ('ERROR' == response.error) {
alert("导入文件失败");
} else {
alert(response.result);
}
return true;
},
'onError' : function(){alert(1);}
});
});
...........
<td align="right" height="35pix" width="40%">
<input name="companyImportFile" id="companyImportFile" type="hidden" />
</td>
求高手帮忙看一下,谢谢!!!.................
补充:.NET技术 , ASP.NET