views:

182

answers:

2

I currently have an ASP.NET, C# page that accepts some text and (currently) one file with the MS AJAXToolKit AsyncFileUpload. However, I want users to be able to upload multiple files - they could upload 1 files or up to 10 files. What's the best way to handle this? Ideally, I'd like them to upload one file at a time, and once that file finishes uploading, another control appears ready to accept another file (or it can remain blank because the user is finished uploading).

So I'm really looking for 2 answers. One is how to handle the GUI side of this and the other is the codebehind - how do I get multiple files when there could 1 or up 10 controls to check?

A: 

If you have access to ASP.NET MVC, take a look here

AllenG
I'd like to find a solution that is based on the AsyncUpload control
Jim Beam
A: 

As to the GUI side, I would say that from the user's point of view -- allow them to select all 10 files at once and hit upload. You can still use your control to upload one at a time, but they can go take a coffeee break and not have to sit and hit upload 10 times.

For the code behind:

protected void ProcessUpload(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
    string fileName = Server.MapPath("./") + "image.jpg";
    AsyncFileUpload1.SaveAs(fileName);

    ScriptManager.RegisterClientScriptBlock(AsyncFileUpload1, AsyncFileUpload1.GetType(), "img",
    "top.document.getElementById('imgUpload').src='image.jpg';", true);
}
NinjaCat