multiple files upload

Discussion in 'ASP .Net' started by andrei, Jun 25, 2003.

  1. andrei

    andrei Guest

    Hi Group,

    In my program, the user has to be able to add one or more documents (as
    files) for one product from the database.
    The number of files to be uploaded can vary from 1 to maybe 30-40 and each
    one will receive a number in a sort order,
    I understand that there is no way to let the user dynamically choose
    multiple files and submit them all at once (like for example as full paths
    in a listbox), so I have to put a <input type=file...> for each file to be
    uploaded.

    Though, what I would like to do is to be able to modify the number of
    displayed <input type=file...> controls on the page, so that I do not have
    to always display the maximum number of controls (and this might not work
    for some situations - what if the user wants to upload 41 files instead of a
    maximum, let's say, of 40 ?)

    What do you think ? Is this a good approach ? Can it be handled other ways ?

    Thank you for any suggestions,

    Andrei.
     
    andrei, Jun 25, 2003
    #1
    1. Advertising

  2. I thnk it's a great approach. Let your user pick the number of controls to
    add, and then do a PostBack and add the controls to the page. On the Server
    Side, Request.Files is already a single Collection, and all you have to do
    is loop through it to get all the files; no need to know how many there are.

    HTH,

    Kevin Spencer
    Microsoft FrontPage MVP
    Internet Developer
    http://www.takempis.com
    Big things are made up of
    lots of Little things.

    "andrei" <> wrote in message
    news:%...
    > Hi Group,
    >
    > In my program, the user has to be able to add one or more documents (as
    > files) for one product from the database.
    > The number of files to be uploaded can vary from 1 to maybe 30-40 and each
    > one will receive a number in a sort order,
    > I understand that there is no way to let the user dynamically choose
    > multiple files and submit them all at once (like for example as full paths
    > in a listbox), so I have to put a <input type=file...> for each file to be
    > uploaded.
    >
    > Though, what I would like to do is to be able to modify the number of
    > displayed <input type=file...> controls on the page, so that I do not have
    > to always display the maximum number of controls (and this might not work
    > for some situations - what if the user wants to upload 41 files instead of

    a
    > maximum, let's say, of 40 ?)
    >
    > What do you think ? Is this a good approach ? Can it be handled other ways

    ?
    >
    > Thank you for any suggestions,
    >
    > Andrei.
    >
    >
     
    Kevin Spencer, Jun 25, 2003
    #2
    1. Advertising

  3. andrei

    Sankalp Guest

    Hi,
    Why not use client script to add an additional "file" control at the click
    of a button. This way a new file control would be shown to the client
    without a postback.
    The control name too can be arrived at dynamically using some name-number
    combination.
    When a post-back does occur, you could probably loop through all the file
    controls and extract the file contents.

    Have not tried this, but should to possible to implement.

    Hope this helps,
    Sankalp



    "andrei" <> wrote in message
    news:%...
    > Hi Group,
    >
    > In my program, the user has to be able to add one or more documents (as
    > files) for one product from the database.
    > The number of files to be uploaded can vary from 1 to maybe 30-40 and each
    > one will receive a number in a sort order,
    > I understand that there is no way to let the user dynamically choose
    > multiple files and submit them all at once (like for example as full paths
    > in a listbox), so I have to put a <input type=file...> for each file to be
    > uploaded.
    >
    > Though, what I would like to do is to be able to modify the number of
    > displayed <input type=file...> controls on the page, so that I do not have
    > to always display the maximum number of controls (and this might not work
    > for some situations - what if the user wants to upload 41 files instead of

    a
    > maximum, let's say, of 40 ?)
    >
    > What do you think ? Is this a good approach ? Can it be handled other ways

    ?
    >
    > Thank you for any suggestions,
    >
    > Andrei.
    >
    >
     
    Sankalp, Jun 26, 2003
    #3
  4. The only PostBack would be the one that adds the "input type=file" elements
    to the page. At that point, the user inputs the files, and submits the form.
    No additional PostBacks necessary. On the server side, you just grab the
    Request.Files Collection. You don't even need to know how many inputs were
    added; the number will be Request.Files.Count.

    HTH,

    Kevin Spencer
    Microsoft FrontPage MVP
    Internet Developer
    http://www.takempis.com
    Big things are made up of
    lots of Little things.

    "andrei" <> wrote in message
    news:%...
    > Thank you, Kevin and Sankalp, for your feedback.
    >
    > I tried both options (client side only vs. round trip to the server to add
    > controls there)
    > Although the client side solution looked better (faster), what if there is

    a
    > need for a postback before actually uploading the files ? I will loose all
    > the dynamically added controls after a reload of the hmtl...
    >
    > So the solution is to show at the beginning a reasonable number of file
    > controls (10, for ex.). If the users need more, they will provide the

    number
    > and click a button, so another "n" controls will be added from the
    > code-behind.
    >
    > Andrei.
    >
    >
     
    Kevin Spencer, Jun 26, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. makthar

    Upload multiple files

    makthar, Nov 13, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    379
    Kevin Spencer
    Nov 13, 2003
  2. =?Utf-8?B?U2hhcmVwb2ludEtpZGE=?=
    Replies:
    2
    Views:
    1,774
    Tommy
    Feb 4, 2004
  3. TK
    Replies:
    1
    Views:
    635
    Eric Lawrence [MSFT]
    Feb 25, 2004
  4. Replies:
    4
    Views:
    984
    M.E.Farmer
    Feb 13, 2005
  5. Chamnap

    Multiple upload with multiple iframe

    Chamnap, Aug 16, 2007, in forum: Javascript
    Replies:
    5
    Views:
    155
    Chamnap
    Aug 17, 2007
Loading...

Share This Page