views:

278

answers:

1

I need the user to be able to upload multiple files to my server, thus I am using the SWFUpload utility. SWFUpload sends the files one by one, and I need to store them all in the same temporary directory. My ASP.NET handler recieves the files one by one and I can store the file appropriately.

My problem is: How do I know which files belong to the same upload? Rephrased, how do I connect the files in my handler?

+1  A: 

I see 2 ways to do this (but they inherit the same idea).

The idea is based on the thing you should have something like sessionId parameter. This value should be unique for each set of files. You could use javascript uuid generators or something like so.

Further, this sessionId variable may be passed through query string(a little bit modified your handler url): ~/UploadHandler.ashx?sessionId={whatever} or as post parameter(guess, the better way). The value may be retrieved on the server side by using: context.Request["SessionId"] for example.

On the client side you should be able to change post parameters or handler url dynamically. It could be done by using:

void addPostParam(name, value)

The addPostParam function adds a name/value pair that will be sent in the POST for all files uploaded.

The name/value pair will also appear in the post_params setting.

or

void setUploadURL(url)

Dynamically modifies the upload_url setting.

client methods. They should be called from the

fileDialogComplete(number of files selected, number of files queued, total number of files in the queued)

The fileDialogComplete event fires after the File Selection Dialog window has been closed and all the selected files have been processed. The 'number of files queued' argument indicates the number of files that were queued from the dialog selection (as opposed to the number of files in the queue).

method.

Hope, this helps.

Alex
@Alex: Thank you for your suggestion. I had a feeling that this was the approach I needed to take, but had hoped for some magic :)
Chau