title: File upload using Put Http method
body: <p>I want to upload a files to a remote server. For this I have read that we could use put method to upload the file. </p>
  
  <p>The user will be provided a form where they can upload one or 2 files. 
  This file should be uploaded to the other server.</p>
  
  <p>The code I have used for file upload using http put is as follows:</p>
  
  <pre><code>$curl = curl_init($api_url);
  $data = array(
    'filename' =&gt; 'filename.html',   
    );
  curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
  curl_setopt($curl, CURLOPT_HEADER, false);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
  curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
  // Make the REST call, returning the result
  $response = curl_exec($curl);
  if (!$response) {
      die("Connection Failure.n");
  }
  </code></pre>
  
  <p>The put request is sent but the file does not get uploaded as required. The file name goes as data. Also the filename.html file is in the root location of the webserver. How do I upload a file? </p>