File uploading from a form with textbox form elements

Discussion in 'ASP .Net' started by Andy Johns, Feb 5, 2004.

  1. Andy Johns

    Andy Johns Guest

    I've seen plenty of examples of file uploads in ASP.NET when the only
    form element is the file input type, but I've not seen a practical
    example of a file upload routine running alongside other form
    elements, e.g. a text box for a description for example. If the form
    is being posted in multipart format then the text coming through will
    need to be converted first, won't it?

    The other issue is that if the form is posted, and the validation
    checks are performed server-side (as they should be, even if you ARE
    using client-side checking) won't the form take ages to process due to
    the file being transferred in the form data?

    I wondered if the webmail style of attachment would be best...where
    you popup a window with a form, you attach the file, you upload it,
    and then all that appears in the original form is a filename. But
    this would mean that the file is already on the server, before you
    actually submit the rest of the form contents, so if they then decide
    to cancel the form, there'll be an orphaned file.

    Is there another way to solve this problem?
     
    Andy Johns, Feb 5, 2004
    #1
    1. Advertising

  2. What I did for a file management sub-system was this:

    I have an aspx page that takes (in the query string) the number of files to
    upload. I have an <input type=file> for each of these files, as well as
    input controls that allow you to fill in several attributes of the file,
    such as a description and other attributes relevant to the application.

    I furthermore have a web service that stores a link to this file, as well as
    an array of names and an equivalent array of values, which form the name
    value pairs. I make a call to the web service to store the link to this
    document, as well as all of the name value pairs.

    The aspx page then simply needs to save the file, and then call the web
    service with the location where it saved it and the name value pairs.

    Later, when I want to view the files, I can query the web service for all
    files with a given name value pair, and it returns that result as a dataset
    which I can display on the form.

    Doing it this way also enables me to use these attachments from any
    application that I want to. All I have to do is give the web service the
    name value pair I want to search by, and it returns the list of documents
    and their locations, as well as the other friendly descriptions I include.

    If you want to display on the fly, and get real data (rather than assumed
    data) you could use this solution as well. You can call the web service on
    the client side (using MSXML) to get the list of documents that are
    relevant, and then you will only see what you have actually finished putting
    up there, rather than assuming that calling this second page means the
    document is there. When you close the window, you can call a method on the
    parent page that re-fetches the list of documents from the server using web
    services.


    --
    Chris Jackson
    Software Engineer
    Microsoft MVP - Windows Client
    Windows XP Associate Expert
    --
    More people read the newsgroups than read my email.
    Reply to the newsgroup for a faster response.
    (Control-G using Outlook Express)
    --

    "Andy Johns" <> wrote in message
    news:...
    > I've seen plenty of examples of file uploads in ASP.NET when the only
    > form element is the file input type, but I've not seen a practical
    > example of a file upload routine running alongside other form
    > elements, e.g. a text box for a description for example. If the form
    > is being posted in multipart format then the text coming through will
    > need to be converted first, won't it?
    >
    > The other issue is that if the form is posted, and the validation
    > checks are performed server-side (as they should be, even if you ARE
    > using client-side checking) won't the form take ages to process due to
    > the file being transferred in the form data?
    >
    > I wondered if the webmail style of attachment would be best...where
    > you popup a window with a form, you attach the file, you upload it,
    > and then all that appears in the original form is a filename. But
    > this would mean that the file is already on the server, before you
    > actually submit the rest of the form contents, so if they then decide
    > to cancel the form, there'll be an orphaned file.
    >
    > Is there another way to solve this problem?
     
    Chris Jackson, Feb 6, 2004
    #2
    1. Advertising

  3. Your post went unanswered. Have you resolved this issue?

    --
    Regards,
    Alvin Bruney [ASP.NET MVP]
    Got tidbits? Get it here...
    http://tinyurl.com/3he3b
    "Andy Johns" <> wrote in message
    news:...
    > I've seen plenty of examples of file uploads in ASP.NET when the only
    > form element is the file input type, but I've not seen a practical
    > example of a file upload routine running alongside other form
    > elements, e.g. a text box for a description for example. If the form
    > is being posted in multipart format then the text coming through will
    > need to be converted first, won't it?
    >
    > The other issue is that if the form is posted, and the validation
    > checks are performed server-side (as they should be, even if you ARE
    > using client-side checking) won't the form take ages to process due to
    > the file being transferred in the form data?
    >
    > I wondered if the webmail style of attachment would be best...where
    > you popup a window with a form, you attach the file, you upload it,
    > and then all that appears in the original form is a filename. But
    > this would mean that the file is already on the server, before you
    > actually submit the rest of the form contents, so if they then decide
    > to cancel the form, there'll be an orphaned file.
    >
    > Is there another way to solve this problem?
     
    Alvin Bruney [MVP], Mar 2, 2004
    #3
    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. Noël®
    Replies:
    0
    Views:
    2,121
    Noël®
    May 25, 2005
  2. Dung Ping
    Replies:
    10
    Views:
    1,061
    Chaddy2222
    Jan 16, 2006
  3. Shufen
    Replies:
    1
    Views:
    269
    Peter L Hansen
    Oct 14, 2004
  4. natzol
    Replies:
    0
    Views:
    511
    natzol
    Dec 1, 2006
  5. Replies:
    4
    Views:
    210
Loading...

Share This Page