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?