#!/usr/bin/perl -- use strict; use warnings; use LWP; use HTTP::Request::Common qw/ POST /; use Encode ; my $url = q[http://localhost/]; my $req = POST( $url, Content_Type => 'multipart/form-data', Content => [ fileuploadfieldname => [ undef, # filename_to_read encode("UTF-8", qq'stupid \x{8216}smart\x{8217} and "quoted" filename.txt'), -content => 'stupid content' ], ], ); dd( $req = $req->as_string ); { $req = HTTP::Request->parse ( $req ); $req = HTTP::Response->new(200, "OK", $req->headers, $req->content ); $req = HTTP::Response->parse( $req->as_string ); $req = HTTP::Response->new(200, "OK", $req->parts ->headers ); dd( $req ); } dd( $req->filename ); sub dd { use Data::Dumper; print Data::Dumper->new([@_])->Useqq(1)->Dump, "\n"; } __END__ $VAR1 = "POST http://localhost/\nContent-Length: 169\nContent-Type: multipart/form-data; boundary=xYzZY\n\n--xYzZY\r\nContent-Disposition: form-data; name=\"fileuploadfieldname\"; filename=\"stupid \350\210\226smart\350\210\227 and \\\"quoted\\\" filename.txt\"\r\n-Content: stupid content\r\n\r\n\r\n--xYzZY--\r\n"; $VAR1 = bless( { "_content" => "", "_rc" => 200, "_headers" => bless( { "content-disposition" => "form-data; name=\"fileuploadfieldname\"; filename=\"stupid \350\210\226smart\350\210\227 and \\\"quoted\\\" filename.txt\"", "-content" => "stupid content" }, 'HTTP::Headers' ), "_msg" => "OK" }, 'HTTP::Response' ); $VAR1 = "stupid \350\210\226smart\350\210\227 and \"quoted\" filename.txt";