How to upload file in asp.net
Hello Guys !
you want to upload file in your web application. just drag the uploadfile control from your toolbox. then drop in your web design page.
Take a Button from your toolbox and drop it in your design page .
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
//if you want to save that particular file in your system anywhere then just give a path where you want to save your file.
FileUpload1.SaveAs("c:\\newfolder\\" + FileUpload1.FileName);
Label1.Text = "recieved" + FileUpload1.FileName + "content type" + FileUpload1.PostedFile.ContentType + "length" + FileUpload1.PostedFile.ContentType;
}
else {
Label1.Text = "no file uploaded";
}
you want to upload file in your web application. just drag the uploadfile control from your toolbox. then drop in your web design page.
Take a Button from your toolbox and drop it in your design page .
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
//if you want to save that particular file in your system anywhere then just give a path where you want to save your file.
FileUpload1.SaveAs("c:\\newfolder\\" + FileUpload1.FileName);
Label1.Text = "recieved" + FileUpload1.FileName + "content type" + FileUpload1.PostedFile.ContentType + "length" + FileUpload1.PostedFile.ContentType;
}
else {
Label1.Text = "no file uploaded";
}
}
Comments
Post a Comment