Downloading Script - To Not to Disclose the Original URL
Downloading Script
Downloading can be done using the urls where the file is present. The Downloading of the file may disclose the actual url to the users.Hacker may get advantage of it and then can browse through that url and can download the files.
so to not to disclose the following script will be used to hide the url.
string filepath = Server.MapPath(”../directoryname/” + filename);
FileInfo file = new FileInfo(filepath);
if (file.Exists)
{
Response.ClearContent();
Response.AddHeader(”Content-Disposition”, “attachment; filename=” + file.Name);
Response.AddHeader(”Content-Length”, file.Length.ToString());
Response.ContentType = “application/pdf”;
Response.WriteFile(file.FullName);
Response.End();
}
Happy Programming
