iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (34)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

May 16, 2008
Who Are Your Top Friends on Facebook?
About
 
May 15, 2008
Reader Question - Would you host your client's work on your website?
About
 
May 15, 2008
How to Create an Ajax Autocomplete Text Field: Part 6
WebReference.com
 
May 14, 2008
Poll: Are the browser safe colors still needed?
About
 
May 14, 2008
Google Doctype launched
About
 
May 14, 2008
Web Editor Reviews - 6 New Reviews
About
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /ASP

Create a "downloads page" and count how many times a file has been downloaded 

  Views:    26367
  Votes:    20
by Romeo Marquez 12/11/03 Rating: 

Synopsis:

An easy example that shows how to build a page with a bunch of downloads if you DO NOT what the users to know the exact path where all of your files are stored. Also learn how to make a downloads counter!
Pages: 
The Article

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 

 

Pages: 



 
  Sponsors