File Field in ASP.NET

K

Kerr

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
 
G

Gold

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top