Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web
Expertise: Intermediate
Oct 2, 1998

Visual InterDev: Logging File Download

Sometimes it is useful to keep track of users' file download activity on your site. When a user clicks on a hyperlink to download a file, you can run an ASP page on the server to log something into SQL Server and then download the file into the client. The trick is to use a hyperlink to launch a second "background" script that logs the filename and initiates the download. If the second script doesn't produce any HTML output, the first page stays on the user's browser screen.

Here's how the hyperlink looks in the first file:

 
<A HREF=dnladd.asp?filename=code.zip>Download code.zip</a>
When the user clicks the hyperlink, we pass the requested filename to the second file,dnladd.asp. Dnladd.asp contains the script and SQL commands that write the filename and other information to the database. After that, dnladd.asp initiates the download withthese lines:
 
Response.ContentType = "application/x-zip-compressed" 
Response.Redirect request("filename")
Remember: don't put any HTML code in dnladd.asp.
Ken Cox
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date