jQuery image upload plugin - multiple instances on single page - ASP.net

Go To StackoverFlow.com

1

I have an ASP.NET web application and on specific page user can add an entry, together with two images. Up until now I have came across many great working jQuery plugins, which can be easily integrated and used for upload. I found this one http://pixelcone.com/jquery/ajax-file-upload-script/ perfect for my needs, it just needs to be cloned.

But the question is: how can I create multiple instances (two in this case) of the same plugin? Just to be clear, I need two plugins which upload a single image each to their location (plugin1->location 1; plugin2->location2).

P.S. By talking about 'two instances' I mean two separate forms as well (not one form with multiple files).

Any comments would be greatly appreciated!

2012-04-04 22:32
by Spartak


0

Use two different selectors when you call the plugin.

e.g.

    $('.fileUploadOne, .fileUploadTwo').fileUploader();

<input type="file" name="file" class="fileUploadOne" multiple>
<input type="file" name="file" class="fileUploadTwo" multiple>

And update your controllers properly with the correct params you want to files to go to.

2012-04-04 22:35
by Christopher Marshall
I tried this as well, but the first uploader stops working in this case.. - Spartak 2012-04-04 22:57
You could try using two different actions on the form. Do you get any JS errors in the console with running the plugin in multiple instances - Christopher Marshall 2012-04-04 22:58
That's the funny part: no errors. The only thing is that the first instance has disabled 'submit' and 'clear' buttons. And when I choose a file, the bottom div doesn't appear... Oh, and I tried with different actions (I just cloned the current ashx handler and renamed it), but the result is the same. The issue is before the form is submitted - Spartak 2012-04-04 23:08
And I might not stated this clearly before, but by two instances I also mean two forms. I'll update the first post - Spartak 2012-04-04 23:16
Ads