in reply to Re: LWP::Useragent - File Upload
in thread LWP::Useragent - File Upload

I'm already using that...See the code posted above. Thanks

Replies are listed 'Best First'.
Re^3: LWP::Useragent - File Upload
by poj (Abbot) on Dec 20, 2018 at 20:24 UTC

    Did you try the code I posted ?

    poj
      As I spent hours to make it finally work, here my working solution:
      my $ua = LWP::UserAgent->new(); my $url = "http://your_url"; my $filename = "d:\\clips\\videoclip.mp4"; my $response = $ua->post($url, ['file' => [ $filename ]], 'Content_Type' => 'form-data' # add here more header paramete +rs if necessary );
        And if you switch to single quotes, you can replace the double backslashes by single ones:
        my $filename = 'd:\clips\videoclip.mp4';
        map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      #!/usr/bin/perl -w use LWP::UserAgent; use JSON; use Encode; use utf8; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; my $url = "xxx"; my $token = 'x'; my $sign = 'xxxxx'; my $file = '/home/xxx/xxxxxxxxxx.jpg'; my $response = $ua->post($url, ["token" => $token, "sign" => $sign, "image" => [$file] ], 'Content_Type' => 'form-data'); if ( $response->is_success ) { print $response->decoded_content,"\n"; } else { die $response->status_line; }

      the file param "image" use an Array "$file"