in reply to upload image with cgi

What do you need to know? You example works uploading a file. You just need to write it to a file. So instead of doing a print to the browser (which would just show the data of the image not the actual image) just write it to a file.

Just check to make sure it's an image and write it to a binmode'ed file handle.

Untested Code:

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 '<img src="/image_dir/filename.jpg">'; } else { print 'Not a JPEG<br>'; }


grep
Mynd you, mønk bites Kan be pretti nasti...