FileUpload


First create a folder in your project directory for example “Upload”

then write this code in your form

<asp:FileUpload ID=”FileUpload1″ runat=”server” />

<asp:Button ID=”Button1″ runat=”server”

onclick=”Button1_Click” Text=”Button” />

then write code behind

protected void Button1_Click(object sender, EventArgs e)

{

if (FileUpload1.FileName != “”)

{

string filename = FileUpload1.FileName;

FileUpload1.PostedFile.SaveAs(

MapPath(“~/Upload/” + FileUpload1.FileName));

}

}


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s