Saturday, July 28, 2007

File Upload

Write this in the HTML Part

Replace "1" with "<" and Replace "2" with ">"

< input type="file" id="FileUpload" size="50" runat="server" />

Write this in the CodeBehind Part
place a button this control and give itz ID as

ID="btnFileUpload" and Text="Upload File"

on itz Button Click write this Function

private void btnFileUpload_Click(object sender, System.EventArgs e)
{
string szFileName = Path.GetFileName(FileUpload.PostedFile.FileName);
FileUpload.PostedFile.SaveAs(Server.MapPath("") + "UploadedFiles/" );
lblMessage.Text = "One File Uploaded SuccessFully";
}

0 comments: