Jquery uploadify uploads files

  • 2020-03-26 23:45:43
  • OfStack

Uploadify also comes with a bunch of parameters and useful methods and callbacks, all in the API. It's all in English, but it's easy to read.
The following is the code I used for reference:


<script type="text/javascript">  
$(document).ready(function() {  
$("#uploadify").uploadify({  
'uploader'       :'images/uploadify.swf',  
'script'         :'<%=request.getContextPath()%>/content/ImportScheduleCommitAction.do',  
'cancelImg'      : 'images/cancel.png',  
'folder'         : '/',  
'queueID'        : 'fileQueue',  
'fileDataName'   : 'uploadify',  
'fileDesc'       : ' Supported formats :xls.',   
'fileExt'        : '*.xls',  
'auto'           :false,  
'multi'          :true,  
'height'         : 20,  
'width'          : 50,  
'simUploadLimit' : 3,  
//'buttonText'     : 'fdsfdsf...',  
'buttonImg'      : 'images/browse.jpg',  
// 'hideButton'     : true,  
// 'rollover'       : true,  
'wmode'          : 'transparent',  
onComplete       : function (event, queueID,fileObj, response, data)  
{   
$('<li></li>').appendTo('.files').text(response);   
},   
onError          : function(event,queueID, fileObj)  
{   
alert(" file :"+ fileObj.name + "  Upload failed ");   
}   
// onCancel         : function(event,queueID, fileObj)  
// {   
//        Alert (" cancel file: "+ fileobj.name);    
// }   
});
<script type="text/javascript">
$(document).ready(function() {
$("#uploadify").uploadify({
'uploader'       : 'images/uploadify.swf',
'script'         :'<%=request.getContextPath()%>/content/ImportScheduleCommitAction.do',
'cancelImg'      : 'images/cancel.png',
'folder'         : '/',
'queueID'        : 'fileQueue',
'fileDataName'   : 'uploadify',
'fileDesc'       : ' Supported formats :xls.',
'fileExt'        : '*.xls',
'auto'           : false,
'multi'          : true,
'height'         : 20,
'width'          : 50,
'simUploadLimit' : 3,
//'buttonText'     : 'fdsfdsf...',
'buttonImg'      : 'images/browse.jpg',
// 'hideButton'     : true,
// 'rollover'       : true,
'wmode'          : 'transparent' ,
onComplete       : function (event, queueID,fileObj, response, data)
{
$('<li></li>').appendTo('.files').text(response);
},  www.th7.cn
onError          : function(event,queueID, fileObj)
{
alert(" file :"+ fileObj.name + "  Upload failed ");
}
// onCancel         : function(event,queueID, fileObj)
// {
//        Alert (" cancel file: "+ fileobj.name);
// }
});

Note that my script property value is a request path, and I found that after I set up multiple files to be uploaded at the same time (for example, 3), instead of uploading 3 files per request, I still executed 3 requests, one file at a time. There's no way to do that. Uplodify has so many callbacks that if you do more than one at a time, you don't know which one to take because none of them are arrays.
That is, no matter how many files you set up to upload at the same time, it will request and upload one by one. It just looks like there are multiple threads processing the upload request at the same time. Also, if you set the simUploadLimit too high, you'll get a lot of errors. When I set it to 5, I often have one or two file uploads fail.


Related articles: