Hi. This is about uploading files with CGI.pm. I read the FAQ for this, used the code posted there, and make some changes, but the main things are the same. This is the code who I use.
Everyting work fine, but there is zero size of uploaded file. Can some tell me where I'm wrong, please. Thanks.
#!/usr/bin/perl
use warnings;
use strict;
no strict 'refs';
use CGI;
my($file, $type, $new, $read, $buffer, @path);
my $cgi = CGI->new();
unless( $file = $cgi->param('FILENAME') )
{
die "no_file";
}
@path = split /\//, $file if $file =~ /\//;
@path = split /\\/, $file if $file =~ /\\/;
$new = '/tmp/debug/';
$new .= pop @path;
open NEW, "> $new" or die $!;
while( $read = read($file, $buffer, 1024) )
{
print NEW "$buffer";
}
close NEW;
P.S. I used exactly the same HTML code, posted in FAQ, of course with changes for my system and cgi file
Everyting work fine, but there is zero size of uploaded file. Can some tell me where I'm wrong, please. Thanks.
#!/usr/bin/perl
use warnings;
use strict;
no strict 'refs';
use CGI;
my($file, $type, $new, $read, $buffer, @path);
my $cgi = CGI->new();
unless( $file = $cgi->param('FILENAME') )
{
die "no_file";
}
@path = split /\//, $file if $file =~ /\//;
@path = split /\\/, $file if $file =~ /\\/;
$new = '/tmp/debug/';
$new .= pop @path;
open NEW, "> $new" or die $!;
while( $read = read($file, $buffer, 1024) )
{
print NEW "$buffer";
}
close NEW;
P.S. I used exactly the same HTML code, posted in FAQ, of course with changes for my system and cgi file