1
我得到'您无权访问此服务器上的/rest/02/put.php。'消息,同时使用以下。curl 403禁止
这是把服务-consumer.php
<?php
$url = 'http://127.0.0.1/rest/02/put.php';
$fh = fopen('data.txt', 'r');
$data = file_get_contents('data.txt');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_INFILE, $fh);
curl_setopt($ch, CURLOPT_INFILESIZE, strlen($data));
curl_setopt($ch, CURLOPT_PUT, true);
curl_exec($ch);
curl_close($ch);
?>
这是把-service.php
<?php
$putdata = fopen("php://input", "r");
echo $putdata."here";
$fp = fopen("put_data_file.txt", "a");
while ($data = fread($putdata, 1024))
fwrite($fp, $data);
fclose($fp);
fclose($putdata);
?>
这是宁静的PHP Web服务本书的例子。虽然get和post作品的例子,删除和放置的例子不起作用。 感谢您提前提供任何帮助。
您的网络服务器是否配置为接受PUT? – 2012-01-12 15:06:11
我在本地使用wamp。我如何检查/启用该功能? – Sami 2012-01-12 15:27:50
嗨,谢谢。我现在配置它。 – Sami 2012-01-12 15:43:33