On Wed, 20 Aug 2003 at 13:29, Merrill Oakes opined:

MO:I have a link to a PDF file on a web page.  I want to count how many 
MO:times that someone clicks on the link (i.e. downloads the PDF).  The 
MO:easy way (at least for me) would be to make them go to a "download page" 
MO:first, and I could put a counter in the page, BUT this requires an extra 
MO:step for the user.
MO:
MO:SO, is there any way to:#1. monitor how many a times a file has been 
MO:downloaded, or maybe #2. have them click on a link (that is really a cgi 
MO:script, that then increments the counter then starts the download/open 
MO:of the PDF?  Of course this last method will disable the ability to do a 
MO:"shift-click" to download the doc.

merrill - i'm a little late on this thread, and the other suggestions are
valid, but here's one way to serve up files w/o using a direct link by
taking advantage of CGI.pm's header() function:

my $cgi = new CGI;

print $cgi->header('application/pdf');

open OUT, '/path/to/some/pdf/file';
my $buffer;

while (my $read = read(OUT, $buffer, 4096)) {
  print $buffer;
}

close OUT;

# insert code here to increment the counter


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to