my $image = upload_file( "file_to_upload.txt", "../incoming" ); sub upload_file { local $| = 1; my( $filename, $path ) = @_; my $file = $query->upload($filename); # the magic open OUTPUT, "> $path/$filename" or die "$path/$filename - $!"; binmode $file; binmode OUTPUT; my $buffer; while ( read( $file, $buffer, 64*2**10 ) ) { print OUTPUT $buffer; } close OUTPUT; close $file; return( $filename ); }