注意:此插件不支持中文,但可以通过其它方式解决

1.修改文件
1). jquery.uploadify.v2.0.3.js 66行 
< if (settings.buttonText) data.buttonText = escape(settings.buttonText); 
                                            改为
> if (settings.buttonText) data.buttonText = encodeURI(settings.buttonText); 
2). uploadify.fla scene 1 脚本文件117行 
< browseBtn.empty.buttonText.text = unescape(param.buttonText); 
                                           改为
> browseBtn.empty.buttonText.text = decodeURI(param.buttonText); 

2.修改标签
  'wmode': 'transparent',  (把flash底色设为透明)
  'buttonText'         改为      'buttonImg': './uploadify/search_h.jpg',    (把文字显示改为图片显示方式就可避开中文乱码)

一,插件的jsp页面配置
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="./uploadify/uploadify.css" />   
<script type="text/javascript" src="./uploadify/jquery-1.4.2.min.js"></script>   
<script type="text/javascript" src="./uploadify/swfobject.js"></script>
<script type="text/javascript" src="./uploadify/jquery.uploadify.v2.1.4.js"></script> 
<script type="text/javascript">
$(document).ready(function()
        {
            $("#uploadify").uploadify({
                'uploader': './uploadify/uploadify.swf',
                'script': './upload.jsp',   //上传文件时设用的方法
                'cancelImg': './uploadify/cancel.png',
                'folder': 'D:/ROOT/upload',//上传文件位于服务器的路径
                'queueSizeLimit' : 3,//同时上传文件数
                'simUploadLimit' : 2,//限制上传的任务数量,当有任务列表中有5个上传任务,系统每次只执行2个,至执行完毕为止
                'multi' :  true,//是否同时上传多个文件
                'method': 'post',
                'auto': false,//是否自动上传
                'wmode': 'transparent',
                'scriptAccess': 'always',  //flash脚本文件的访问模式,如果在本地测试设置为always,默认值:sameDomain
                 'buttonImg': './uploadify/search_h.jpg',
                'fileDesc' : 'rar文件或zip文件' , //出现在上传对话框中的文件类型描述
                 'fileExt'   : '*.rar;*.zip',      //控制可上传文件的扩展名,启用本项时需同时声明fileDesc
                'sizeLimit': 86400,           //控制上传文件的大小,单位byte
                'removeCompleted' : false,   //上传完成后不自动清空任务列表
               'onSelect'    : function(event,ID,fileObj) {
                   //当每成功选择一个文件时执行此函数
                     alert(ID);
                     if(fileObj.size>300){
                     //alert('The file ' + fileObj.name + ' was added to the queue.');
                     }
                  },

               'onComplete'  : function(event, ID, fileObj, response, data) {
                 //当上传成功一个文件就执行一次此函数
                                 

                      event: 事件对象

                       queueID: 完成文件的唯一标识符。

                      fileObj:  

                     ? name – 文件名

                     ? filepath –上传路径

                     ? size – 文件大小

                      ? creationDate – 文件创建时间

                      ? modificationDate –文件最近修改时间

                      ? type –文件的扩展名

                     response: 服务器回调的数据

                     data:  

                    ? fileCount – The total number of files left in the queue(文件数目)

                    ? speed – 平均上传速度 KB/s


                 
                  }  ,

                'onAllComplete' : function(event, data) {//当所有文件上传完成后的回调函数,ajax方式哦~~ 

                         
                    alert(data.speed);  
                }  
            
               // 'buttonText' : '浏览'
            });
        }); 

</script>  
<title></title>
</head>
<body>
<div id="fileQueue"></div>
    <input type="file" name="uploadify" id="uploadify" />
   <p>
      <a href="javascript:$('#uploadify').uploadifyUpload()">上传</a>| 
      <a href="javascript:$('#uploadify').uploadifyClearQueue()">取消上传</a>
    </p>
</body>
</html>

posted on 2011-08-21 01:03  SNS  阅读(411)  评论(0)    收藏  举报