Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > <input type="file"

Reply
Thread Tools

<input type="file"

 
 
Pai
Guest
Posts: n/a
 
      08-29-2003
Hello there,

Good Morning,

I am facing a peculiar problem.

I have the following code in the html section of my .apsx page

<input type="file" runat="server" id="fileBrowse" NAME="fileBrowse">

and the following code in my code behin:

string srcUrl = System.IO.Path.GetFullPath(fileBrowse.PostedFile.F ileName);
string srcFileName =
System.IO.Path.GetFileName(fileBrowse.PostedFile.F ileName);

Stream fStream = fileBrowse.PostedFile.InputStream;
byte[] contents = new byte[fStream.Length];
fStream.Read(contents, 0, (int)fStream.Length);
fStream.Close();

I also have another server side control whcih is a button

<asp:button id="AddUser" runat="server" Text="test">

when I click on this button and then try to upload the file, the
reference to the file which has to be uploaded is lost....

and fileBrowse.PostedFile.FileName holds value = ""....

I am not able to figure out how to go about this....

any idea why this is happening....

Kind Regards,
Srikanth Pai
 
Reply With Quote
 
 
 
 
Pai
Guest
Posts: n/a
 
      09-02-2003
"Teemu Keiski" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> Just checking that do you have the <form runat="server" ...> set with
> enctype="multipart/form-data" attribute as it is needed for uploading to
> work?
> --
> Teemu Keiski
> MCP, Designer/Developer
> Mansoft tietotekniikka Oy
> http://www.mansoft.fi
>
> AspInsiders Member, www.aspinsiders.com
> ASP.NET Forums Moderator, www.asp.net
> AspAlliance Columnist, www.aspalliance.com
>


Hello Keiski,

I have included all these in the form tag.

The problem here is that since the button is a asp.net server control
it fires the postback event and the contents of the <input type="file"
is lost and the value becomes "" when I click the button.

I want the value to persist even after the post back....

Any suggestions,

Kind Rergards,
Srikanth Pai
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments