title: cURL http post file upload using curl --data in linux command line
body: <p>I have been trying to upload the file to the server using this command in linux command line:</p>
  
  <pre><code>curl -v --data 'file=@/var/www/fbapp/images/registration.png' http://myserver/xmltest/curlupload.php
  </code></pre>
  
  <p>but it is not uploading the file to the server, even though it is sending the response back.</p>
  
  <p>Although if I use this command it will upload the file and send the response back:</p>
  
  <pre><code>curl -v -F 'filename=registration.png' -F 'file=@/var/www/fbapp/images/registration.png' http://myserver/xmltest/curlupload.php
  </code></pre>
  
  <p>But I wanted the command in the <strong>curl --data</strong> format itself.</p>
  
  <p>This is my PHP code in the server:</p>
  
  <pre><code>&lt;?php
  $uploadpath = "images/";
  $filedata = $_FILES['file']['tmp_name'];
  echo "filedata= ".$filedata;
  if ($filedata != '')
  copy($filedata,$uploadpath."1.png");
  echo "success";
  ?&gt;
  </code></pre>
  
  <p>And this is the header response that I get back:</p>
  
  <pre><code>&gt; POST /xmltest/curlupload.php HTTP/1.1
  &gt; User-Agent: curl/7.22.0 (i686-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
  &gt; Host: myserver
  &gt; Accept: */*
  &gt; Content-Length: 44
  &gt; Content-Type: application/x-www-form-urlencoded
  &gt; 
  * upload completely sent off: 44out of 44 bytes
  &lt; HTTP/1.1 200 OK
  &lt; Date: Thu, 06 Nov 2014 07:01:56 GMT
  &lt; Server: Apache
  &lt; Vary: Accept-Encoding
  &lt; Transfer-Encoding: chunked
  &lt; Content-Type: text/html
  &lt; 
  * Connection #0 to host myserver left intact
  * Closing connection #0
  filedata= success
  </code></pre>
  
  <p>How can I use <strong>curl --data</strong> to upload the file?</p>