#!/usr/bin/perl -wT #use CGI; use CGI qw(warningsToBrowser fatalsToBrowser); #use CGI::Carp qw(warningsToBrowser fatalsToBrowser); $CGI::POST_MAX = 10000000; # Added as an example - limit POST to 10000k my $q = new CGI; # Create new query object my $filename = $q->param("pic"); my $upload_filehandle = $q->upload("pic"); # Corrected my $upload_dir="/pics"; $filename =~ s/.*[\/\\](.*)/$1/; print $q->header ("text/html" ); open UPLOADFILE, ">$upload_dir/$filename"; binmode UPLOADFILE; # to specify binary file operations on this filehandle my $total_bytes = 0; while (my $bytes_read = read($upload_filehandle, $buffer, 1024)) { print UPLOADFILE $buffer; $total_bytes += $bytes_read; } close $upload_filehandle; close UPLOADFILE; print ""; print ""; print "Thanks..!!!"; # note closing head tag print ""; print "

Thanks for uploading your photo!

"; print "

Your photo:

"; print ""; print "

Size of photo is $total_bytes bytes.

"; # Added line if desired. print ""; print ""; ####
Photo to Upload: