title: how to upload file using curl with PHP
body: <p>I want to know how to upload file using cURL or anything else in PHP. I have searched in google many times but no results.</p>
  
  <p>In other words, the user sees a file upload button on a form, the form gets posted to my php script, then my php script needs to re-post it to another script (eg on another server).</p>
  
  <p>I have this code to receive the file and upload it</p>
  
  <p>code : </p>
  
  <pre><code>echo"".$_FILES['userfile']."";
  $uploaddir = './';
  $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
  if ( isset($_FILES["userfile"]) ) {
      echo '&lt;p&gt;&lt;font color="#00FF00" size="7"&gt;Uploaded&lt;/font&gt;&lt;/p&gt;';
      if (move_uploaded_file
  ($_FILES["userfile"]["tmp_name"], $uploadfile))
  echo $uploadfile;
      else echo '&lt;p&gt;&lt;font color="#FF0000" size="7"&gt;Failed&lt;/font&gt;&lt;/p&gt;';
  }
  </code></pre>
  
  <p>I want the code to send the file to receiver file.</p>