title: Using cURL to upload POST data with files
body: <p>I would like to use cURL to not only send data parameters in HTTP POST but to also upload files with specific form name. How should I go about doing that ?</p>
  
  <p>HTTP Post parameters:</p>
  
  <p>userid = 12345
  filecomment = This is an image file</p>
  
  <p>HTTP File upload:
  File location = /home/user1/Desktop/test.jpg
  Form name for file = image (correspond to the $_FILES['image'] at the PHP side)</p>
  
  <p>I figured part of the cURL command as follows:</p>
  
  <pre><code>curl -d "userid=1&amp;filecomment=This is an image file" --data-binary @"/home/user1/Desktop/test.jpg" localhost/uploader.php
  </code></pre>
  
  <p>The problem I am getting is as follows:</p>
  
  <pre><code>Notice: Undefined index: image in /var/www/uploader.php
  </code></pre>
  
  <p>The problem is I am using $_FILES['image'] to pick up files in the PHP script.</p>
  
  <p>How do I adjust my cURL commands accordingly ?</p>