Hi,

I've discovered a solution.

I don't know anything about databases yet but I've  noticed that if the file
that the script tries to download includes http://server _name, the file
keeps its name.

If your $location variable is something like
/path/file.zip
it won't keep its name, but if you will add in the code
http://yourserver.domain.com$location it will keep its name.

I don't know why it works only this way (I would like to know)  but I've
tried it and it works.

HTH.

Teddy,
My new email address is [EMAIL PROTECTED]

----- Original Message -----
From: "Matthew Harrison" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 04, 2002 8:58 PM
Subject: Dowload script


I have written the following script to let people download files from a web
browser without displaying the actual location, utilising a MySQL database.
It works ok, except that it renames the file download.cgi (the name of my
script). How can I make it keep the proper name?

<script posted here>

#!/usr/bin/perl

use CGI qw/:standard/;
use CGI::Carp "fatalsToBrowser";
use DBI;


#####Get Input

$filenum = param('file');


#####Get Database Data

$dbh = new CGI;
$dbh=DBI->connect("DBI:mysql:database=misc;host=127.0.0.1;port=3306",downloa
ds,downloads);
die "Could not connect to database" if !$dbh;

$sth = $dbh->prepare("SELECT location FROM downloads WHERE filenum =
'$filenum'");
if ($sth && $sth->execute()){
    @results = $sth->fetchrow_array();
}
$location = $results[0];


#####Redirect to File

print "Location: $location\n\n";
exit;


</script posted here>

--
Matthew Harrison
Internet/Network Services Administrator
Peanut-Butter Cheesecake Hosting Services
Genstate
www.peanutbuttercheesecake.co.uk

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



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

Reply via email to