to uplaod file on server
protected void btnSub_Click(object sender, EventArgs e)
{
try
{
string filename = FileUpload1.FileName;
string filename1 = FileUpload2.FileName;
FileUpload1.PostedFile.SaveAs(Server.MapPath("~\\Uploadform\\" + filename.Trim()));
FileUpload2.PostedFile.SaveAs(Server.MapPath("~\\Uploadform\\" + filename1.Trim()));
string path = "~\\Uploadform\\" + filename.Trim();
string path1 = "~\\Uploadform\\" + filename1.Trim();
SqlConnection con = new SqlConnection(str);
cmd = new SqlCommand("Insert into Circular(title,type,url1,url2) values('" + txttitle.Text + "','" + txttype.Text + "','" + path + "','" + path1 + "')", con);
lblinfo.Text = " Uploaded Successfully ";
cmd.CommandType = CommandType.Text;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
your file can be simply download/open as
Response.Redirect(pdfurlfetchfromdatabase);