OK ... according to  perldoc CGI ( i have CGI.pm v2.98 )
To be safe, use the upload() function (new in version 2.47). When called with the name of an upload field, upload() returns a filehandle, or undef if the parameter is not a valid filehandle.

$fh = $query->upload('uploaded_file');
while (<$fh>) {
print;
}

everything looks fine ... but what if you want to do something different with the tmpfile?

I'm trying to pass it into Image::Magick, like so:

my $fh = $self->cgi->upload( 'map' ); my $thumb = Image::Magick->new(); $thumb->Read( file => \*$fh ) or die "No read to Image::Magick ob +j: $! \n";

it always dies on the read.

if  $fh ( according to the docs ) is a filehandle, and Image::Magick expects a glob ref to a filehandle, what am i missing?

i've tried adding the full path to the image. no love.


In reply to CGI::upload and Image::Magick by geektron

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.