PHP 5.3.6을 사용하고 있으며 CUT을 사용하여 PUT 요청을 만들 수 없습니다.PHP에서 CURL을 사용하여 PUT 요청하기
function put_data($url, $data)
{
$useragent="SimpleAgent-1.0";
$fh = fopen('php://memory', 'rw');
fwrite($fh, $data);
rewind($fh);$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_INFILE, $fh);
curl_setopt($ch, CURLOPT_INFILESIZE, strlen($data));
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_PUT, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
fclose($fh);
return $result;
}
여기에서 $ data는 내가 PUT 할 문자열입니다. 작동 다음과 같은 오류를 반환하지 않습니다 :
난 당신의 코드가 너무 URL을 정의하는 문자열과 데이터를 작성하고 예상대로 모든 일을 사용500 Internal Server Error The server has either erred or is incapable of performing the requested operation.
expected string or buffer
PHP에'error_log'가 있습니까? – alex
되감기 전에 닫으려고합니다 ($ fh); 어쨌든 아파치 로그를 읽으십시오 – ZiTAL
되감기 후에 죄송합니다 ($ fh); – ZiTAL