clear swf upload queue:


// request your stat objects, it contains amongst others the number of files in the queue
var stats = my_upload.getStats();
// while the queue is not empty ...
while (stats.files_queued > 0) {
  // .. cancel the first in the queue (null: take the first found, false: don't trigger an error event)
  my_upload.cancelUpload(null, false);
  // it is important to reload the stats everytime and not just do a for (i = 0; i < stats.files_queued ...
  stats = my_upload.getStats();
}
This can be done by thisway in handler.js:


function uploadAnnoncePhotoSuccess(file, serverData) {
 try {
  var progress = new FileProgress(file,  this.customSettings.upload_target);

  if (serverData.substring(0, 9) === "FILENAME:") {
   $(".photo_loading").hide();
   var imgName=serverData.substring(9);
   tabImgs[tabImgs.length] = imgName;
   setImgsTab();
   //copy annonce is like a new annonce.
   if (id_annonce && 'copy'!=photoAction){
    $.post("/controller/annonce/annonce_gestion.php?action=addPhoto", "id_annonce="+id_annonce+"&nom_photo="+imgName);
   }
   var img='url(/data/photos/big/'+imgName +')';
   $("#imagDetail").css("background-image", img);
   $("#img_detail_hidden").attr('src',"/data/photos/big/"+imgName);
   $("#zoneNumImg a[alt="+imgName+"]").click(); 
   
   progress.setStatus("Upload Complete.");
   progress.toggleCancel(false);
  } else {
   //addImage("images/error.gif");
   progress.setStatus("Error.");
   progress.toggleCancel(true);
   var stats = this.getStats();
   // while the queue is not empty ...
   while (stats.files_queued > 0) {
     // .. cancel the first in the queue (null: take the first found, false: don't trigger an error event)
     this.cancelUpload(null, false);
     // it is important to reload the stats everytime and not just do a for (i = 0; i < stats.files_queued ...
     stats = this.getStats();
   }
  
   var msg1 = microtime(true); 
   showMessage(
     msg1,
     serverData,
     null,
     null,
     function(){
      MSGClose(msg1); 
   });

   $(".photo_loading").hide();   
  }


 } catch (ex) {
  this.debug(ex);
 }
}

评论

热门博文