title: Change name of upload file in cURL?
body: <p>I want to upload a file using cURL. Since cURL requires full path to the file so here is my code:</p>
  
  <pre><code>curl_setopt($ch, CURLOPT_POSTFIELDS, array("submit" =&gt; "submit", "file" =&gt; "@path/to/file.ext"));
  curl_exec($ch);
  </code></pre>
  
  <p>However cURL will also post this full path of the file in the request header:</p>
  
  <blockquote>
    <p>Content-Disposition: form-data; name="file"; filename="/path/to/file.ext"</p>
  </blockquote>
  
  <p>But I want it to be just</p>
  
  <blockquote>
    <p>Content-Disposition: form-data; name="file"; filename="file.ext"</p>
  </blockquote>
  
  <p>So I change the code to</p>
  
  <pre><code>curl_setopt($ch, CURLOPT_POSTFIELDS, array("submit" =&gt; "submit", "file" =&gt; "@file.ext"));
  chdir("path/to"); # change current working directory to where the file is placed
  curl_exec($ch);
  chdir("path"); # change current working directory back
  </code></pre>
  
  <p>And then cURL simply throws an error message</p>
  
  <blockquote>
    <p>couldn't open file "file.ext" </p>
  </blockquote>
  
  <p>Can anybody tell me how to do it please?</p>