Hi all,
Here is my first attempt to write this script. I will be adding the protection/whitelisting/etc. after I get the basic this running. Here is what I have so far, and here is what happens. On a PC, the dialog box comes up and saves the file, but it is 0K -- nothing in it. On a Mac, the "Downloads" dialog box comes up, but the progress bar keeps spinning and nothing happens. Below is the HTML that calls the script and the CGI script itself. What did I forget/do wrong?
Thanks,
Mark
-------------------------------------------------------------
<html>
<head>
<title>Untitled Page</title>
</head>
<body>
<a href="javascript:window.location='cgi-bin/download.cgi?picname=Upload- Background.gif'">picture link</a>
</body>
</html>
-------------------------------------------------------------
#!/usr/bin/perl -w
use strict; use CGI ':standard';
my $filename = param('picname'); my $path = "/images/$filename";
binmode STDOUT; print "Content-Disposition: attachment;filename=$filename\n"; print "Content-Type: application/octet-stream\n\n";
open (FILE, "> $path") || die("Can't open($filename): $!"); my $data = <FILE>; close (FILE);
print $data;
exit;
---------------------------------------------------------
On Aug 23, 2004, at 2:45 PM, Joel Rees wrote:
I think that's what I'm looking for. One question. What do you mean "whitelist" the filepaths". My only reference point is email. "Whitelist" for me means that email address on my "whitelist" always get through, even though the spam software might initially think it's spam. Can you clarify?
If the script I posted was readable, you might have noticed that it accepts one parameter and sets the directories only if that parameter matches correctly. It looks like a waste, but it's one way of what he was calling whitelisting in a fairly strict way, but allowing the same script to be used on multiple sets of images. You do have to add a little code for each set of images, of course.
That script needs some comments.
--
Joel Rees
Getting involved in the neighbor's family squabbles is dangerous.
But if the abusive partner has a habit of shooting through his/her roof,
the guy who lives upstairs is in a bit of a catch-22.