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
This works for me...
function put($_server,$_file,$_data)
{
$fp = @fsockopen ($_server, 80, $errno, $errstr, 30);
if ($fp)
{
$p = "PUT $_file HTTP/1.0\r\n";
$p.= "User-Agent: Mozilla/3.0 (Windows NT 5.0; U) Opera 7.21 [da]\r\n";
$p.= "Host: $_server\r\n";
$p.= "Accept: text/html, application/xml;q=0.9, application/xhtml+xml;q=0.9, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\n";
$p.= "Accept-Language: da;q=1.0,en;q=0.9\r\n";
$p.= "Accept-Charset: windows-1252, utf-8, utf-16, iso-8859-1;q=0.6, *;q=0.1\r\n";
$p.= "Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0\r\n";
$p.= "Referer: http://www.nasa.gov/secret/flightplans.asp\r\n";
$p.= "Content-type: application/x-www-form-urlencoded\r\n";
$p.= "Content-length: ".strlen($_data)."\r\n";
$p.= "\r\n";
$p.= $_data;
//echo($p);
fputs ($fp, $p);
}
else die("dagnabbit : $errstr");
while ($l=fgets($fp))
echo($l);
fclose($fp);
}
Many of the header lines are probably not necessary... but it works when I talk to my couchdb so I haven't gotten around to weeding them out.