Response.ContentType = "application/x-unknown";
string fileName = "file.jpg";
string filePath = "d:\\" + fileName;
Response.AddHeader("Content-Disposition","attachment; filename=" + fileName );
FileStream fs = File.OpenRead(filePath);
BinaryReader br = new BinaryReader(fs);
Response.BinaryWrite(br.ReadBytes(Convert.ToInt32(fs.Length)));
Response.End();
This is code in c#. Similar way you can use this in any other scripting language.
Tags: Response.ContentType, Content-Disposition, ASP.NET, C#, Download a file using c# and ASP.NET
No comments:
Post a Comment