Teresa Raymond wrote:
>
> Dear fliptop:
>
> Yes sir! That is exactly what I want to do.
ok, good. see below for my thoughts.
> >Teresa Raymond wrote:
> >>
> >> OK, I am a relative novice to Programming, Perl, CGI, CGI.pm and
> >> MIME::Lite. As suggested by others on this list I'm using MIME::Lite.
> >> I've written the below code with part of a MIME::Lite example copied.
> >> I've put the whole code here because I'm not sure what to leave out.
> >> The actual problem occurs at during the sub main section where the
> >> line reads: my $filepath = $ARGV[0] || die "missing path to
> >> FILE\n"; The output is a blank screen, no error messages, just
> >> nothing happens.
> >
> >ok, let me see if i understand what you want to do.
> >
> >1) upload an image via a browser.
> >2) verify the uploaded file is an image.
i recommend using Image::Size instead of the code you had:
use Image::Size qw{ imgsize };
my ($x, $y, $id) = imgsize($fh); # $fh is the handle to your file
my $found = 0;
# include only the image types you're interested in
foreach (qw{ GIF JPG XBM XPM PPM PGM PBM PNG TIF BMP }) {
$found = 1 if $id eq $_;
}
die "unacceptable type" unless $found; # or however you want to exit
# code to put image on server goes here
> >3) email the image as an attachment to someone.
use MIME::Lite;
my $msg = new MIME::Lite
From => '[EMAIL PROTECTED]',
To => '[EMAIL PROTECTED]',
Subject => qq{Here's your image},
Type => 'TEXT',
'Reply-to' => '[EMAIL PROTECTED]',
Data => qq{Here is the image that was uploaded. Enjoy.};
attach $msg
Type => 'image/jpg', # or whatever image type it is
Encoding => 'base64',
Path => 'image1.jpg'; # assuming that's the image name
$msg->send;
i typed this in without testing it, let me know if it doesn't work.
also, i assumed you weren't having trouble uploading and writing the
image to the server.