use warnings; use CGI qw/:standard/; use CGI::Carp 'fatalsToBrowser'; use POSIX; print header, start_html('upload form'); my $filename = "text.txt"; binmode($filename); print start_form(), table( Tr( td("File: "), td(filefield(-name=>'upload', -size=>50, -maxlength=>80), ), ), Tr( td(), td(submit('button','submit'), ) ) ), end_form(), hr; if (param()) { my $upload = param('upload'); while (<$filename>) { print; } open (OUTFILE,">>/home/myname/public_html/upload/text.txt") || die $!; binmode(OUTFILE); while ($bytesread=read($filename,$buffer,1024)) { print OUTFILE $buffer; print "the thing is open"; } print "The file should be uploaded if everything went right, which it probably didn't.\n"; }