title: Which headers for file upload in Perl?
body: <p>I've been stuck on this for quite a couple of hours and I haven't been able to find a solution for it by researching.</p>
  
  <p>The following HTML code will work for what I require:</p>
  
  <pre><code>&lt;form action="uploader.php" method="POST" enctype="multipart/form-data"&gt;
  &lt;label for="file"&gt;Filename:&lt;/label&gt;
  &lt;input type="file" name="Filedata" id="file" /&gt;
  &lt;br /&gt;
  &lt;input type="submit" name="submit" value="Submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>However, the following Perl code does not work. I assume this is because I'm not sending the headers required.</p>
  
  <pre><code>my @headers  = ('Content-Disposition' =&gt; 'form-data; name="Filedata"; filename="test.txt"',
                  'Content-Type'        =&gt; 'text/plain',
                  'Content'             =&gt; 'File content goes here.');
  
  my $browser  = LWP::UserAgent-&gt;new;
  my $response = $browser-&gt;post('uploader.php', undef, @headers);
  </code></pre>
  
  <p>If anyone can point out the reason it doesn't work I would be grateful.
  Thank you!</p>