Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Bugs after error
  • Hi,

    I need some help because I don't understand the uploadify's logic after an error occur.

    I read this post but nothing change : viewtopic.php?f=7&t=2499&p=4903&hilit=onerror#p4903

    This is my code

    <script type=\"text/javascript\">
    $(document).ready(function() {
    $(\"#uploadify\").uploadify({
    'uploader': '../jscript/jquery/plugin/uploadify/uploadify.swf',
    'script': 'Upload.ashx',
    'cancelImg': '../img/cancel.png',
    'folder': '../Documents',
    'auto': true,
    'multi': false,
    'buttonText': 'Ajouter un fichier',
    'wmode': 'transparent',
    onComplete: function(event, queueID, fileObj, reposnse, data) {
    //Here my ajax / asp.net method to update a database },
    onAllComplete: function(event, data) {
    //do nothing
    },
    onError: function(event, queueID, fileObj, errorObj) {
    if (fileObj.size > 4 * 1024 * 1024) {
    alert(\"Vous ne pouvez pas transemttre des fichiers de plus de 4 Mo.\");
    }
    else {
    alert(\"Une erreur est survenu lors de l'envoi de votre fichier\");
    }
    $('#uploadify').uploadifyClearQueue();
    }
    onError: function() {
    window.setTimeout(\"cancelError('\" + arguments[1] + \"')\", 1000);
    }

    });
    });
    function cancelError(id) {
    try{
    $('#uploadify').uploadifyCancel(id); //---> fire a bug sometimes
    }catch (ex) {
    //do nothing
    }
    }
    </script>


    This is my scenario :
    1 - Upload first file less than 4Mb
    2 - Upload second file less than 4 Mb
    Here, all is good
    3 - Upload a file greater than 4 Mb
    My asp.net handler 'Upload.ashx' throw error because the size is upper to 4 Mb
    3.a - the "onError" method fire
    4 - Upload another file less than 4 Mb
    [EDIT]4.b my handler throw an error[/EDIT: Wrong, My handler doesn't throw an error, it work fine]
    4.c the "oncomplete" method is fire 4 time (because I send 4 files).

    Some idea ?

    Regards
  • I really think this is a bug because I made some other test with the same result (if I can, I publish my demo site so you can see and understand by yourselfl what I said)

    I have find a (bad) solution. When error occur, I bind an array with the queueID and when no error append, in oncomplete, I I bind another array with the queueID

    In each method (oncomplete and onerro) I test if the queueId is not an old queueId, if ti is, I return false, else, I continue the method.


    var MesErreurs = [];
    var MesSucces = [];$(document).ready(function() {
    $(\"#uploadify\").uploadify({
    'uploader': '../jscript/jquery/plugin/uploadify/uploadify.swf',
    'script': 'Upload.ashx',
    'cancelImg': '../img/cancel.png',
    'folder': '../Documents',
    'auto': true,
    'multi': false,
    'buttonText': 'Ajouter un fichier',
    'wmode': 'transparent',
    'sizeLimit': '4194304', //4Mo
    onComplete: function(event, queueID, fileObj, response, data) {
    //test si queueID est pas un ancien upload en erreur
    for (z = 0; z < MesErreurs.length; z++) {
    if (MesErreurs[z] == queueID) {
    return false;
    }
    }
    var Succes = new Array(queueID);
    MesSucces.push(Succes);

    UpdateFichierPunaise(fileObj.name, $(\"#H_MEM_ID_PUNAISE\").val());

    },
    onError: function(event, queueID, fileObj, errorObj) {

    //test si queueID est pas un ancien upload réalisé avec succes
    for (z = 0; z < MesSucces.length; z++) {
    if (MesSucces[z] == queueID) {
    return false;
    }
    }

    var Error = new Array(queueID);
    MesErreurs.push(Error);
    if (fileObj.size > 4 * 1024 * 1024) {
    alert(\"Vous ne pouvez pas transemttre des fichiers de plus de 4 Mo.\");
    }
    else {
    alert(\"Une erreur est survenue lors de l'envoi de votre fichier\");
    }
    }
    });
    });


    Regards