According to the CGI.pm documentation, section PROCESSING A FILE UPLOAD FIELD, your code should look something like this:

use CGI; my $cgi = CGI->new(); my $lightweight_fh = $cgi->upload('client_local_offer_image_url'); # undef may be returned if it's not a valid file handle if (defined $lightweight_fh) { # Upgrade the handle to one compatible with IO::Handle: my $fh = $lightweight_fh->handle(); open (my $OUTFILE, '>', 'some_file_path') or die "Couldn't open output file: $!"; while (my $bytes_read = $fh->read($my chunk_of_data, 1024) ) { print {$OUTFILE} $chunk_of_data; } }

Also this from Programming Perl:

CGI does not designate how web servers should handle output to STDERR, and servers implement this in different ways, but they almost always produces a 500 Internal Server Error reply. Some web servers, like Apache, append STDERR output to the web server's error log, which includes other errors such as authorization failures and requests for documents not on the server. This is very helpful for debugging errors in CGI scripts.

Other servers, such as those by iPlanet, do not distinguish between STDOUT and STDERR; they capture both as output from the script and return them to the client. Nevertheless, outputting data to STDERR will typically produce a server error because Perl does not buffer STDERR, so data printed to STDERR often arrives at the web server before data printed to STDOUT. The web server will then report an error because it expects the output to start with a valid header, not the error message. On iPlanet, only the server's error message, and not the complete contents of STDERR, is then logged.

Note that if you are doing line oriented input, perl will automatically convert any newlines(\n) it reads to \r\n on Windows, which will corrupt the data in an image file if there are any \n characters in the image file.

Also, you might want to read the following sitepoint article on sanitizing the file name for file uploads:

http://articles.sitepoint.com/article/uploading-files-cgi-perl

In reply to Re: File upload is refusing to work by 7stud
in thread File upload is refusing to work by ultranerds

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.