Welcome Guest Search | Active Topics | Sign In | Register

Multiple AJAXUploaders Options
TML
Posted: Wednesday, April 8, 2009 3:00:37 PM
Rank: Newbie
Groups: Member

Joined: 4/8/2009
Posts: 5
Hi,

I have a requirement in which I need three separate AJAXUploaders on one page to upload files to three separate directories. I know the 'ClientSideOnDone' attribute executes a client side method when the upload is complete. I want a client side function to fire only after all three uploads are complete. How would I implement this?

Many thanks,

TML
eo_support
Posted: Wednesday, April 8, 2009 3:25:52 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

There are several ways to do that. The easiest way is to set the uploader's Rows property to 3 and then upload all three files in one pass. You will use a single uploader and handle a single ClientSideOnDone event. The down side for this approach is that even you set the uploader to have three rows, user can still leave two empty and only upload one file.

A more sophisticated way is to simply remember which uploader's ClientSideOnDone has been called. For example, you can have something like this:

Code: JavaScript
var g_flags = new Array();

function on_uploader1_done()
{
   on_uploader_done(1);
}

function on_uploader2_done()
{
   on_uploader_done(2);
}

function on_uploader2_done()
{
   on_uploader_done(3);
}

function on_uploader_done(n)
{
    g_flags[n] = true;

    if (g_flags[1] && g_flags[2] && g_flags[3])
   {
        //All three uploaders are done...now do 
        //whatever you want to do here
        ....
   }
}


Note this only works if you do not postback the page in between the three uploads. Once the page post back, the value you stored in g_flags will be lost. If you need to do postback anyway, it will be easier for you to use a single Uploader and then in a "now give me the first file", "now give me the second file" manner.

Whether all three files go to the same directory or different directory is irrelatively less important. You can always handle the file uploader's FileUploaded event and move the file to wherever you wanted them to be.

Hope this helps.

Thanks
TML
Posted: Wednesday, April 8, 2009 3:36:12 PM
Rank: Newbie
Groups: Member

Joined: 4/8/2009
Posts: 5
Thank you for your quick reply!

TML


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.