We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 38,297 times

Related Categories

Uploading Files Using ASP.NET

manfrommars

Add a file browse HTML control. Right click and select 'Run as Server Control'. Add a button. So you have something like this:

<input type="file" runat="server" ID="File1" /><asp:Button runat="server" ID="Button1" /> 

Double click the button and add the following code.

private void Button1_Click(object sender, System.EventArgs e)
{
string strFilename;

try
{
strFilename = File1.PostedFile.FileName;
strFilename = System.IO.Path.GetFileName(strFilename);
File1.PostedFile.SaveAs(@"f:\"+strFilename);
}
catch(Exception ex)
{
Response.Write(ex);
}
}

Comments