CGI.pm Question

Craig Freter cfreter at digex.net
Tue Aug 31 08:48:44 CDT 1999


Chris,

Since this script runs as a CGI, you need to print out an HTTP header.

> Hi.
> 
> I've been trying to get the below script to work, but so far, this is what
> happens:
> 
> After doing chmod 777 on the directory where the files are to be uploaded,
> the script will create an empty file in the upload directory, the name
> returned by
> param('filename') really is the file name, however, nothing uploads.  The
> script is activated by a web browser using a form with an upload file field
> in a form.
> 
> Using perl -c -w, the syntax checks out OK and there are no warnings except
> that the $bytesread scalar is pointed out as occuring only once, which can
> be forgiven here.
> 
> What could be wrong?
> 
> Thanks in advance, Chris Shannon (Shannon Design)
> 
> #!/usr/bin/perl
> use lib '/http/yourwebsite/mylib';
> use CGI qw(:standard);
> 
> $ofn = '/http/yourwebsite.com/upload/upfile.dmp';
> 
> $| = 1;
> 
> $fh=param('filename');
> open OUTFILE, ">$ofn";
> 
> while ($bytesread=read($fh,$buffer,1024)) {
>    print OUTFILE $buffer;
> }
> 
> close($fh);
> close(OUTFILE);
> 
> chmod (0666, "$ofn");

-- 
All that is complex is not useful,
and all that is useful is simple.
                       -- Mikhail Kalashnikov



More information about the Baltimore-pm mailing list