I enabled HTTP PUT on my apache web server and I'm using this cgi script to handle HTTP PUT request
Code: Select all
<?php
//------ This is the cgi script I'm using handle PUT request
/* PUT data comes in on the stdin stream */
$putdata = fopen("php://input", "r");
/* Open a file for writing */
$fp = fopen("myputfile.ext", "w");
/* Read the data 1 KB at a time
and write to the file */
while ($data = fread($putdata, 1024))
fwrite($fp, $data);
/* Close the streams */
fclose($fp);
fclose($putdata);
?>
Code: Select all
$host="localhost";
$port = 80;
// open a client connection
$sock_stream = fsockopen ($host, $port, $errno, $errstr);
if (!$sock_stream)
{
$result = "Error: could not open socket connection";
}
else
{
$message = "PUT /temp.file HTTP/1.1\r\nHost: localhost\r\n\r\nthis is the sample text";
fputs ($sock_stream, $message);
// get the result
$result = fgets ($sock_stream, 1024);
fclose ($sock_stream);
}
echo $result;
pls help me in finding out whats going wrong.