2012-01-12 191 views
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作品的例子,刪除和放置的例子不起作用。 感謝您提前提供任何幫助。

+0

您的網絡服務器是否配置爲接受PUT? – 2012-01-12 15:06:11

+0

我在本地使用wamp。我如何檢查/啓用該功能? – Sami 2012-01-12 15:27:50

+0

嗨,謝謝。我現在配置它。 – Sami 2012-01-12 15:43:33

回答