Forum Moderators: coopster & phranque

Message Too Old, No Replies

File download and logging

         

cdorman

8:45 pm on Jun 11, 2004 (gmt 0)

10+ Year Member



I have a simple web page that allows a user to download some files (currently just hrefs to them). I want to log the downloads to a file. I replaced the href with a submit button, which I am handling in a perl script. In the html form, I have:

<form method="POST" action="/cgi-bin/logger.cgi">
<input type="submit" value="Data.txt" name="file1" id="download1">
</form>

and in the perl script I can nicely see that the person has clicked on the button and what they clicked on, and can write it to a file (i'm using the CGI module and I do $query->param('file1'). In the same directory as the html file I have the file they want (call it data.txt"). How do I start the download?

I want the user to be returned to the download page. Right now, I do that with
print $query->redirect($downloadURL);
and that works.

So, basically, everything works except the user doesn't get the file :-) How do I do that?

volatilegx

9:48 pm on Jun 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try just sending this header:

print "Location: [domain.com...]

cdorman

2:55 am on Jun 14, 2004 (gmt 0)

10+ Year Member



Ah....thanks. My perl code doesn't actually
have to do anything to the page, just launch the
download. I was sending it basically the same
URL it was at, but that's not necessary because
if I do as you say, the URL doesn't change.

Thanks again.

kalos

10:02 am on Jul 18, 2004 (gmt 0)

10+ Year Member



Of course this doesn't keep someone from hotlinking to the file itself, but that's another matter altogether. ;)