in reply to Re^2: Attempting to POST a file to local server
in thread Attempting to POST a file to local server
I too found the phrasing confusing but it is correct as stated
A value of form_data (an error) is treated as "application/x-www-form-urlencoded"
A value of form-data is treated as "multipart/form-data"
#!/usr/bin/perl -- use strict; use warnings; use LWP; my $ua = LWP::UserAgent->new; $ua->add_handler("request_send", sub { shift->dump; return }); $ua->add_handler("response_done", sub { shift->dump; return }); $ua->timeout( 0.1 ); my $res = $ua->post('http://localhost:8012/', #~ Content_Type => 'form_data', ## treated as "application/x-www-f +orm-urlencoded" Content_Type => 'form-data', ## treated as "multipart/form-data" #~ Content_Type => 'multipart/form-data', Content => [ Filedata => [ __FILE__, 'Hello.txt', Content_Type => 'text/plain', ], submit => 'Submit', ], );
|
|---|