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. Advertisements

  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. Advertisements

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. Luqman
    Replies:
    4
    Views:
    7,084
    Luqman
    Jan 25, 2006
  2. =?Utf-8?B?QW5hbmRoaQ==?=

    How to call a ASP.net file from ASP file

    =?Utf-8?B?QW5hbmRoaQ==?=, Apr 19, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    394
    Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
    Apr 19, 2007
  3. NotGiven
    Replies:
    3
    Views:
    579
    Michael D. Kersey
    May 13, 2004
  4. Scott Gordo
    Replies:
    1
    Views:
    240
    Kyle Peterson
    Mar 23, 2006
  5. NotGiven
    Replies:
    3
    Views:
    515
    Michael D. Kersey
    May 13, 2004
  6. Sound
    Replies:
    2
    Views:
    754
    Randy Webb
    Sep 28, 2006
  7. VUNETdotUS
    Replies:
    25
    Views:
    915
    Thomas 'PointedEars' Lahn
    Nov 10, 2007
  8. jr
    Replies:
    3
    Views:
    696
Loading...