I\'ve been struggling for several hours trying to figure out how to get this work. I\'m trying to send a file via HTTP-PUT to an eXist db. There is user authentication for
function _publish($service, $doc) {
$params = array(
'http' => array(
'method' => 'PUT'));
$context = stream_context_create($params);
$fp = fopen($service, 'rb', false, $context);
$response = fwrite($fp,file_get_contents($doc));
if ($response === false) {
return false;
}
// Pull out the status code from the header
$metaData = stream_get_meta_data($fp);
preg_match_all("/HTTP\/1\.[1|0]\s(\d{3})/", $metaData['wrapper_data'][0], $matches);
$code = end($matches[1]);
if ($code == 200) {
return true;
} else {
return false;
}
}
from http://www.littlehart.net/atthekeyboard/2008/01/11/how-to-http-put-a-file-somewhere-using-php/