Add a asp file upload control to your page
Now add new button btnsave (save button)
add this code on btnsave click
protected void btnsave_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile == false)
{
label.Text = "Please select a file ";
}
else
{
// Note UploadedFiles is a folder Name in the Project.
string filePath = Server.MapPath("~/UploadedFiles/" + FileUpload1.FileName);
FileUpload1.SaveAs(filePath);
Label2.Text = "File Uploaded succesfully";
}
This is a very basic File uploading in C# .Also Please take care of security aspect,max file size,delete file after use,same names etc parameters into account .
Thanks
Now add new button btnsave (save button)
add this code on btnsave click
protected void btnsave_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile == false)
{
label.Text = "Please select a file ";
}
else
{
// Note UploadedFiles is a folder Name in the Project.
string filePath = Server.MapPath("~/UploadedFiles/" + FileUpload1.FileName);
FileUpload1.SaveAs(filePath);
Label2.Text = "File Uploaded succesfully";
}
This is a very basic File uploading in C# .Also Please take care of security aspect,max file size,delete file after use,same names etc parameters into account .
Thanks