Fliptop certainly got the guts of your program right.
If you expect to see those 'die' messages in your browser
you should look at CGI::Carp. Sort of like this:
use CGI::Carp qw(fatalsToBrowser set_message);
BEGIN {
sub handle_errors {
my $msg = shift;
print h1('Oh gosh');
print p, "Got an error: $msg";
print p, "Please send the text of this error message to: ";
print a({-href=>'mailto:[EMAIL PROTECTED]',
'[EMAIL PROTECTED]');
}
set_message(\&handle_errors);
}
-will
Fliptop wrote:
>
> 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.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]