Sending file to HTTP POST request

时间:2018-03-25 20:24:16

标签: perl file-upload

I have an HTML form which contains a file upload control. I want to send that file to the Content key of the header of an HTTP POST request. The HTML control returns C://fakepath//.. location when I upload a file from front end.

Do I need to upload the file first on my server to send it as a request header for the POST call?

Here's the code I am trying to achieve.

<div class="row">
    <input name ="file" type="file"/>
</div>
my $url = 'http://testserver:12313/myfile';

my @headers = (
    'Content_Type' => 'form-data',
    'Content'      => [ file =>   [ "testfile.pl" ]]
);

my $browser = LWP::UserAgent->new;

my $resp = $browser->post($url, @headers);

0 个答案:

没有答案