CGI.pm Question

Chris Shannon cshannon at mdo.net
Tue Aug 31 06:51:05 CDT 1999


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");






More information about the Baltimore-pm mailing list