File Field in ASP.NET

Discussion in 'ASP .Net Web Controls' started by Kerr, Feb 9, 2005.

  1. Kerr

    Kerr Guest

    Hi all,
    Sorry, i'm new to asp.net (coming from a VB.NET background) and finding
    it difficult to achieve something that is rather simple.

    I have a simple aspx page that contains a file form (I am not sure if
    there is a .net control that allows file selection, and if there is can
    someone please tell me where it is?)

    Also on this page is a submit button. When I click the submit button,
    my code behind does a request.form("file1") to set a declared string to
    the value in the form field. However, what is return is always
    "Nothing"..

    Does anyone have any idea why this is?

    Also, can someone tell me the best way to achieve selecting a file from
    my local file system and working with the value in that file field.

    I am looking for the .net way of doing this and not the simplist way.

    Cheers in advance..

    Kerr



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Kerr, Feb 9, 2005
    #1
    1. Advertising

  2. Kerr

    Gold Guest

    Hi,

    it's simle, but there is no web form file control, so you have to use the
    file control available under HTML controls. and set the runat property of
    that control to server.
    In your button event use the following statement to get the uploaded file
    details
    (assume the control is named as fileCntrl)

    fileCntrl.PostedFile.FileName -- gives you the selected file name
    fileCntrl.PostedFile.FileStream -- gives you the stream obj ref, so u can
    read the contents of the file, and store it into a DB or folder, whatever way
    you want.


    Regards,
    :) Thangam




    "Kerr" wrote:

    > Hi all,
    > Sorry, i'm new to asp.net (coming from a VB.NET background) and finding
    > it difficult to achieve something that is rather simple.
    >
    > I have a simple aspx page that contains a file form (I am not sure if
    > there is a .net control that allows file selection, and if there is can
    > someone please tell me where it is?)
    >
    > Also on this page is a submit button. When I click the submit button,
    > my code behind does a request.form("file1") to set a declared string to
    > the value in the form field. However, what is return is always
    > "Nothing"..
    >
    > Does anyone have any idea why this is?
    >
    > Also, can someone tell me the best way to achieve selecting a file from
    > my local file system and working with the value in that file field.
    >
    > I am looking for the .net way of doing this and not the simplist way.
    >
    > Cheers in advance..
    >
    > Kerr
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    >
    Gold, Feb 9, 2005
    #2
    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. NotGiven
    Replies:
    3
    Views:
    344
    Michael D. Kersey
    May 13, 2004
  2. Scott Gordo
    Replies:
    1
    Views:
    159
    Kyle Peterson
    Mar 23, 2006
  3. Sound
    Replies:
    2
    Views:
    438
    Randy Webb
    Sep 28, 2006
  4. VUNETdotUS
    Replies:
    25
    Views:
    452
    Thomas 'PointedEars' Lahn
    Nov 10, 2007
  5. jr
    Replies:
    3
    Views:
    416
Loading...

Share This Page