ArmandoG has asked for the wisdom of the Perl Monks concerning the following question:
and here is the CGI for it<html><head> <title>Download Page</title> </head> <body> <form action="/cgi-bin/download.cgi"> <p> <select size="1" name="ID"> <option value="0001.jpg">File One </option> <option value="file.zip">File Two </option> </p> </select> <input type="submit" value="Submit" name="B1"> </form> <br><br>...or here is an example of using a link to call the script: + <a href="/cgi-bin/download.cgi?ID=file.zip">Download File</a> </body> </html>
Can someone help me to find out where is the error? Thanks#!c:\perl\bin\perl.exe use CGI ':standard'; use CGI::Carp qw(fatalsToBrowser); my $files_location; my $ID; my @fileholder; $files_location = "c:\files\err"; $ID = param('ID'); if ($ID eq '') { print "Content-type: text/html\n\n"; print "You must specify a file to download."; } else { open(DLFILE, "<$files_location/$ID") || Error('open', 'file'); @fileholder = <DLFILE>; close (DLFILE) || Error ('close', 'file'); print "Content-Type:application/x-download\n"; print "Content-Disposition:attachment;filename=$ID\n\n"; print @fileholder } sub Error { print "Content-type: text/html\n\n"; print "The server can't $_[0] the $_[1]: $! \n"; exit; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Error of the argument
by derby (Abbot) on Dec 27, 2007 at 19:31 UTC | |
by almut (Canon) on Dec 27, 2007 at 20:35 UTC | |
|
Re: Error of the argument
by CountZero (Bishop) on Dec 27, 2007 at 19:46 UTC |