Working With Uploadify And Multiple Fields In A Page


Uploadify is a jQuery plugin by which you can create the file upload functionality. You can know more about the plugin or download it in this page http://www.uploadify.com/. The problem I faced with one of my projects is using uplodify in multiple fields in a single page.

Here is the code which did the trick.

$('.myupload').each(function() {
    var $myupload = $(this);

    $myupload.uploadify({
        'uploader': '/images/uploader.swf',
        'cancelImg': '/images/cancel.png',
        'script': 'ajax_call.php',
        'auto'      : true,
        'removeCompleted' : false,
        'wmode': "transparent",
        'hideButton'  : false,
        'multi': false,
        'displayData': 'percentage',
        'scriptData'  : ....for any script data you want to send.... ,
        'onSelect'    : ....write here the function which you want to execute when the field is selected....,
        'onComplete'  : function(event, ID, fileObj, response, data) {
           ..... put here the code you want to execute when the file is completely uploaded..... 
        }
    });
});

Here I placed the class "myupload" in all the fields of the page where I wanted the uploadify to work.