Using uploadifive for multiple file upload causes repeated invocations of check_exists

Viewed 1727

Am using uploadifive (the HTML5 version not the the Flash based uploadify) as follows:

$('#file_upload').uploadifive({ //setup uploadify
    'auto'             : false,
    'removeCompleted'  : true,
    'checkScript'    : 'check-exists.php',
    'formData'         : {
                              'timestamp' : '<?php echo $timestamp;?>',
                              'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
                         },
    'queueID'          : 'queue',
    'uploader'         : 'uploadifive.php',
    'onUploadFile'     : function(file) {
                            //alert('The file ' + file.name + ' is being uploaded.');
                         },
    'onCheck'          : function(file, exists) {
                           //alert ('onCheck: ' + file.name + '/' + exists);
                         },
    'onUploadComplete'  : function(file, data) { 
                          //alert (file.name + ': ' + data); 
                         }
});

With this simple form:

<form>
    <div id="queue"></div>
    <input id="file_upload" name="file_upload" type="file">
    <a style="position: relative; top: 8px;" href="javascript:$('#file_upload').uploadifive('upload')">Upload Files</a>
</form>

If I load one or two files into an empty folder, all works fine.
If I load 3 or more I get a variable number of repeated calls to check_info.php. For instance if I upload five files into an empty folder, according to firebug there are 15 calls to check_info.
1 for file 1, returns 0 (ie file does not exist)
2 for file 2, both return 0
3 for file 3, all return 0
4 for file 4, 1 returns 0 and 3 return 1 (ie file exists)
5 for file 5, 2 return 0, 3 return 1
The multiple returns of 0 I can live with (though it's very inefficient) as they are invisible to the user, but the 6 returns of 1, each generate a warning msg to which the user has to respond.
I have no idea why this happening. Have looked at uploadifive code but it's way beyond my limited knowledge of jQuery.
Appreciate any advice/suggestions/cures/etc
Tx in advance

1 Answers
Related