TStanley has asked for the wisdom of the Perl Monks concerning the following question:

Ok, I am attempting to write a file upload form, and a cgi script to deal with it. Right now, I am mainly just testing my logic. I am doing my testing on a Redhat Linux 7.2 server running the latest version of Apache. HTML Code for the form and for the script follow:
<HTML> <HEAD><TITLE>Upload Form</TITLE></HEAD> <BODY><CENTER> <FORM METHOD="POST" ACTION="cgi-bin/upload.cgi"> File Name:&nbsp;&nbsp;&nbsp;<INPUT TYPE="FILE" NAME="file"> <BR><BR><BR> <INPUT TYPE="SUBMIT" VALUE="Submit"> </FORM> </CENTER></BODY> </HTML>
And now the script:
#!/usr/bin/perl -w # I am not using taint yet, but when I get # ready to deploy this, it will be there use strict; use CGI; my $Q=new CGI; my $File=$Q->param('file'); # I know what I am sending right now # so when I turn on tainting, the below # regex will DEFINITELY be changing if($File=~/\/root\/text/){ print $Q->header; print $Q->start_html('File is Correct'); print $Q->h1("File is $File"); print $Q->end_html; }else{ print $Q->header; print $Q->start_html('File is Incorrect'); print $Q->h1("File is $File"); print $Q->end_html; }
The error in the log is stating that the $File variable is undefined, which means that the form isn't passing the name. Please just point me in the right direction, and I should be able to handle it from there.

TStanley
--------
It is God's job to forgive Osama Bin Laden. It is our job to arrange the meeting -- General Norman Schwartzkopf

Replies are listed 'Best First'.
Re: Uploading a file with CGI
by cLive ;-) (Prior) on Sep 15, 2002 at 22:45 UTC
    If you'd looked in the CGI Q & A section, you might have seen this.

    .02

    cLive ;-)

    ps - hint - $File is a filehandle.

    --
    seek(JOB,$$LA,0);

Re: Uploading a file with CGI
by Kanji (Parson) on Sep 15, 2002 at 22:30 UTC
Re: Uploading a file with CGI
by Ryszard (Priest) on Sep 16, 2002 at 08:35 UTC
    Just the other day I posted this...
Re: Uploading a file with CGI
by blm (Hermit) on Sep 16, 2002 at 11:45 UTC

    Yes and here I was putting my 2cents in. There is a URL in my post with some demo html and perl code. Also look up CGI::Upload on CPAN or do a search for it on perl monks. CGI::Upload is written by btrott a saint 'round here.