jquery.uploadify.3.2.1 trial in IE9,IE10 upload file button will not be able to click

Keywords: JQuery JSON

I used to use version 2.1.4. After seeing the update, I tried it and found that there were many changes.

First, introduce js and css

  1. <link rel="stylesheet" href="uploadify.css" />  
  2.  <script src="jquery.uploadify.js"></script>  
  3. Of course, jquery is essential

Next is the code:

  1. //File upload  
  2. $(function() {    
  3.     $("#uploadify").uploadify({    
  4.        'auto' : false,    
  5.        'method' : "post",    
  6.        'height' : '20',    
  7.        'width' : '100',    
  8.        'swf' : 'uploadify.swf',     
  9.        'uploader' : '<%=basePath%>/contract/fileUpload.action',    
  10.        'fileTypeDesc' : 'format:txt,xls,xlsx,doc,docx',     //Description  
  11.        'fileTypeExts' : '*.txt;*.xls;*.xlsx;*.doc;*.docx;*.zip',            //File type  
  12.        'fileSizeLimit' : '10000KB',         //File size  
  13.        'buttonText' : 'Select file',           //Button name  
  14.        'fileObjName'    :'uploadify',    
  15.        'successTimeout' : '5',    
  16.        'requeueErrors' : false,    
  17.        'removeTimeout' : '1',    
  18.        'removeCompleted' : true,    
  19.        'onUploadSuccess' : function(file, data, response){    
  20.             var attach = eval('(' + data + ')');    
  21.             $("#fileTable").show();    
  22.             var addHtml = "<tr>"+    
  23.                             "<td class='t_l'>"+    
  24.                                 "<a href='<%=basePath%>/attach/downloadAttach.action?attachId="+attach.id+"'>"+attach.filename+"."+attach.fileextname+"</a>"+    
  25.                             "</td>"+    
  26.                             "<td class='t_r'>"+attach.filesize+"</td>"+    
  27.                             "<td class='t_c'>"+attach.uploaddate+"</td>"+    
  28.                             "<td class='t_c'><a href='<%=basePath%>/attach/downloadAttach.action?attachId="+attach.id+"' id='"+attach.id+"'>download</a></td>"+    
  29.                             "<td class='t_c'><a href='#' onclick='removeFile(this)' id='"+attach.id+"' name='attach_id'>cancel</a></td>"+    
  30.                           "</tr>";    
  31.             $("#fileBody").append(addHtml);    
  32.         }    
  33.     });    
  34. });    



Where onUploadSuccess is the callback function after successful upload file is the uploaded file. You can get the file name size through file.name to get the size

data is the string output by the background reponse. In the above example, the output is a json object, so eval is used for conversion

response is the result true or false. Please refer to official documents for details.

  1. <td colspan="3">    
  2.     <input type="file" name="uploadify" id="uploadify" />    
  3.     <input type="button" value="upload" onclick="$('#uploadify').uploadify('upload','*');">    
  4.     <input type="button" value="cancel" onclick="$('#uploadify').uploadify('stop');">    
  5.     <table style="display: none;" id="fileTable">    
  6.         <tbody style="width: 550px;border: solid;border-color: #D0D0D3;" id="fileBody">    
  7.             <tr style="border: solid;border: #D0D0D3;">    
  8.                 <td width="200px;" class="t_c">file name</td>    
  9.                 <td width="100px;" class="t_c">Size(k)</td>    
  10.                 <td width="150px;" class="t_c">Upload time</td>    
  11.                 <td width="100px;" class="t_c" colspan="2">operation</td>    
  12.             </tr>    
  13.         </tbody>    
  14.     </table>    
  15. </td>    

You can see that many properties in the initialization have changed, including the function name of the upload operation and so on.


Secondly, there is another problem. The button of uploading the file in IE9 can't be clicked. The initial check may be caused by the problem of flash. Baidu later found that the classid in the source js can be modified.

For details, please refer to:

http://www.cnblogs.com/donhwa/archive/2011/06/23/ie9_swfupload_bug.html


js replacement file download after solving this problem

http://files.cnblogs.com/lostboy/jquery.uploadify3.1.fixed.js

or

http://download.csdn.net/detail/chenxiang199055/6003627

Posted by jdimino on Fri, 01 May 2020 05:46:54 -0700