Why doesn't this work?

J

jend

See scripts below: I get zero sized files. and an error message in the logs
like this: readline() on unopened filehandle at upload.cgi

It seems that the follwing line is failing in my code

+++ my $upload_filehandle = $query->upload("myfilename");

but this is almost exactly the same as the perldoc CGI docs sample.

anyone?


This is the upload script
#!/usr/local/bin/perl

use strict;
use warnings;

use CGI;
use CGI::Carp qw(fatalsToBrowser);

$CGI::DISABLE_UPLOADS = 0;

my $upload_dir = '/tmp/upload.txt;

my $query = new CGI;
my $filename = $query->param('myfilename');

print $filename;

$filename =~ s/.*\/\\(.*)/$1/;

print $filename;

my $upload_filehandle = $query->upload("myfilename");

open(UPLOADFILE, ">$upload_dir/$filename") or die $!;

binmode UPLOADFILE;

while ( <$upload_filehandle> )
{
print UPLOADFILE;
}
close UPLOADFILE;
print $query->header ( );
 
B

Bob Walton

jend said:
See scripts below: I get zero sized files. and an error message in the logs
like this: readline() on unopened filehandle at upload.cgi

It seems that the follwing line is failing in my code

+++ my $upload_filehandle = $query->upload("myfilename");

but this is almost exactly the same as the perldoc CGI docs sample.
....


Quick dumb guess:

my $upload_filehandle = $query->upload("myfilename");

$filename--------------------------------^^^^^^^^^^^^

Your code is trying to upload the literal filename "myfilename". That's
probably not the name of the file you actually want to upload.
....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top