<script type="text/javascript">
$(function() {
$('#file_upload').uploadify({
swf:'<%=basePath%>dwz/uploadify/scripts/uploadify.swf',
uploader:'<%=basePath%>Admin/Public/upload.html',
auto : true,
'fileSizeLimit' : '7000KB',
'fileTypeDesc' : 'All Files',
//'fileTypeExts' : '*.doc; *.docx;',
'fileTypeExts' : '*.jpg;*.png;*.gif;*.bmp; *.doc; *.docx;',
buttonText : '请选择附件',
'onUploadSuccess' : function(file, data, response) {
//每个文件上传成功后会调用,可能会两次
//alert('文件[' + file.name + ']上传成功了,' + response + '返回值:' + data);
$("#shownode").append(
"<p>已成功上传" + file.name + "文件</p>");
document.getElementById("file").value = file.name;
var obj = jQuery.parseJSON(data);
var dataObj = eval("(" + obj.message + ")");//截取message部分转换为json对象
//解析list对象
var arr = eval(dataObj.root);
var ret = "";
for ( var i = 0, arrLength = arr.length; i < arrLength; i++) {
var arrobj = arr[i];
//alert(arrobj.id+arrobj.value);
var node = "<p><a href='#' >解析返回值->编号"
+ arrobj.id + ",值为:" + arrobj.value
+ "</a></p>";
ret = ret + node;
//$("#shownode").append(node);
}
$("#shownode").append(ret);
},
'onQueueComplete' : function(queueData) {
alert(queueData.uploadsSuccessful + ' 个文件上传成功!');
$("#shownode").append(
"<p>已成功上传"
+ queueData.uploadsSuccessful
+ "个文件</p>");
}
});
});
</script>