First, let’s say you want to build a page with a bunch of downloads but DO NOT what the users to
know the exact path where all of your files are stored.
If you use the following link it would totally reveal the path:
<a href=”downloads/winxp/manual.pdf”>
So what you can do in order to hide this information is to build an intermediate asp file that will launch the download without revealing the actual path.
The new link would look like this:
<a href=”downloads.asp?file=manual.pdf”>
Here’s the code to downloads.asp
<%
Option explicit
Dim strFile
strFile=request..querystring(“file”)
response.redirect “downloads/winxp/”&strfFile
%>
When downloads.asp is called, the browser will prompt a window for the user to either open or save the file! This way the path will be hidden from the user and it will remain a secret!
You might also want to keep track of how many times has a file being downloaded.
To do so, you would only need to add that a little code before the respose.redirect
|
<%
Option explicit
Dim strFile
strFile=request..querystring(“file”)
‘Begins code to update the downloads counter
Set conexion= server.createobject("adodb.connection")
Set rs=server.createobject("adodb.recordset")
strSql="select * from downloads where file='" & strFile &"'"
conexion.open YourStringConnection
rs.open strSql,conexion,1,3
rs("counter")=cint(rs("counter"))+1
rs.Update
rs.Close
Set rs=nothing
conexion.Close
Set conexion=nothing
‘Ends Code to update the downloads counter
response.redirect “downloads/winxp/”&strfFile
%> |
By using this example you will manage your downloads in a more professional way!
Questions?
Write me, Romeo Marquez Guzman romeo@gelattina.com
www.gelattina.com