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 (35)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

July 2, 2009
June Stats: What's Happening at Web Design @ About.com
About
 
July 2, 2009
Get free RSS feeds on 500 topics or make your own custom feeds!
WebDevTips UK
 
July 2, 2009
Microsoft's Bing Takes a Nibble Out of Google's Search Share
WebDevTips UK
 
July 2, 2009
States fire shots in Internet sales tax war
WebDevTips UK
 
July 2, 2009
Mrs Slocombe's pussy vanishes from Twitter
WebDevTips UK
 
July 2, 2009
More privacy choices in Facebook revamp
WebDevTips UK
 
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:    221743
  Votes:    73
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