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; } }