Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I read the FAQ, but it don't work

Status
Not open for further replies.

gremolin

Programmer
Oct 3, 2002
18
0
0
BG
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
 
I'm sorry for this post. This is my second post for this think. I have found my error, and it's is funny error, but... :)))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top