Download Code
string filename = "filename from Database";
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + filename);
string aaa = Server.MapPath("~/SavedFolder/" + filename);
Response.TransmitFile(Server.MapPath("~/SavedFolder/" + filename));
Response.End();
Upload Code
string FilePath = "";
string[] a = new string[1];
string fileName = "";
string FullName = "";
if (FileUploader.FileName.Length > 0)
{
a = FileUploader.FileName.Split('.');
fileName = Convert.ToString(System.DateTime.Now.Ticks) + "." + a.GetValue(1).ToString();
FilePath = Server.MapPath(@"~\SavedFolder");
Fup1.SaveAs(FilePath + @"\" + fileName);
FullName = FilePath + @"\" + fileName;
// Database Saved Code
}
Reference
http://www.codeproject.com/Tips/185886/File-Upload-and-Download-in-ASP-NET
No comments:
Post a Comment