Downloading Script - To Not to Disclose the Original URL

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

Leave a Reply


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.