my $filename = $cgi->param('uploaded_file'); my $type = $cgi->uploadInfo($filename)->{'Content-Type'}; #use the upload function if ($type eq 'image/jpeg') { open(IMAGE,">/image_dir/filename.jpg"); my $fh = $cgi->upload('uploaded_file'); binmode(IMAGE); while (<$fh>) { print IMAGE $_; } print ''; } else { print 'Not a JPEG
'; }