Link to home
Start Free TrialLog in
Avatar of MOSSPOINT
MOSSPOINTFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Uploading multiple files using web application and vb.net

Hi Experts,

I am developing a vb.net web application and have a form with a fileupload contol and it does what is says, uploads a file from the clients browser to my server.

So how can I extend this control to select multiple files in one go, without using javascripr or other 3rd party downloads (becasue I don't know how to use these technologies.

Please include code to show me how this is done.  Thanks.
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Its not possible to upload more than one file using UploadControl at the same time.

You can do something like adding the uploaded file to the session variable and then once user clicks on Upload button, you can upload the files stored in session at the same time
Avatar of sybe
sybe

Why not use multiple UploadControls?
@sybe:- If it is user's choice to upload as many files he wants, then adding specific number of multiple upload controls won't work
> adding specific number of multiple upload controls won't work

I am aware of that. But you could decide on a maximal number of files and then have that number of UploadControls. It seems a bit crazy to have the user upload 145 files in one go. Uploading so many files through http has it's own problems.

Of course there are all kinds of more or less fancy solutions to overcome the fact the browser-based file-upload is based on picking files individually, but the asker does not want to use third party controls nor javascript. That limits the solution quite a lot.

I do not see how uploading a file to a session variable is different from uploading a file to a physical directory on the server (at least not from the users point of view).

If user wants to cancel some file then by some selection, we can remove that file from session variable and while uploading, upload only those files which are there in the session instead of removing the uploaded files from the server machine.
Having binary code in the session might cause a memory problem. What if a user uploads a 100MB file? Would you keep the binary code in a session variable?

Oh, and just to notice: if you mean to store just the filepath in session, that is not going to work. Fileupload controls don't accept predefined values. That includes values from a session variable.
@sybe:- I agree that, Due to security permission, only storing the file path will not work
Avatar of MOSSPOINT

ASKER

I'm just amazed there's an upload control but not a control that returns a list of files the user has selected  and then allows my code to feed the filenames in to file upload function?
Due to client machine's security concerns, only one file per upload control is allowed
Have you checked my link? It has something that lets you do that.
> I'm just amazed there's an upload control but not a control that returns a list of files the user has selected  and then allows my code to feed the filenames in to file upload function?

It is not as simple as that. Fileupload has a huge security risk. It must be absolutely prevented that files are uploaded without the user explicitly picking the file. Furthermore the basis of a form in HTML is a corresponce between one <input> and one <value>. Because forms are submitted as key/value pairs.

If there would be one <input> for multiple files, it means a redefinition of how HTML forms are processed, and that isn't something that will happen in the near future (or anytime).
emoreau

I didn't really want to use flash etc.. but if this is the only solution, how do I use/incorporate it in my solution?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks