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-perlIn reply to Re: File upload is refusing to work
by 7stud
in thread File upload is refusing to work
by ultranerds
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |