Q:

Upload file with put PHP Curl

I need to send data to my own server for test.
I've found such implementation.
 <?php 
        $data = array("a" => $a);
        $ch = curl_init($url);

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
        curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($data));

        $response = curl_exec($ch);
        if(!$response) {
            return false;
        }
        else
        {
            echo"OK";
        }
?>

This says "OK" so script is working. But how can I send a file? This is my attempts:
HTML:
  <form action="upload.php" method="put" enctype="multipart/form-data">
  <input type="file" name="filename"><br> 
  <input type="submit" value="Load"><br>
  </form>

PHP:
 <?php 
        $data = $_FILES['filename']['tmp_name']
        $ch = curl_init('http://xmpp1.feelinhome.ru/');

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
        curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($data));

        $response = curl_exec($ch);
        if(!$response) {
            return false;
        }
        else
        {
            echo"OK";
        }
?>

This doesn't says "OK" so my script is wrong. Where is my mistake how can I send file?

A:

As phihag states in their answer:

According to the HTML
  standard, you can not. The only valid values for the method
  attribute are get and post, corresponding to the GET and POST HTTP
  methods. <form method="put"> is invalid HTML and will be treated
  like <form>, i.e. send a GET request.

Try to change form method to post
 <form action="upload.php" method="post" enctype="multipart/form-data">

Also set in curl
curl_setopt($ch, CURLOPT_POST, 1);

