0
framework - fuelphp 1.7Fuelphp rest PUT issue
我嘗試從服務器上傳文件到另一個文件。
發送我使用捲曲。
$url = "http://files.loc/api/upload";
$body = 'data that I want to send';
$fp = fopen('php://temp/maxmemory:256000', 'w');
if (!$fp) {
die('could not open temp memory data');
}
fwrite($fp, $body);
fseek($fp, 0);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PUT, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, strlen($body));
$output = curl_exec($ch);
curl_close($ch);
在其他服務器上接收數據看起來像
class Controller_Api_Upload extends Controller_Rest {
public function put_index()
{
$content = file_get_contents("php://input");
$file = fopen('./images/txt.txt', 'w+');
fwrite($file, $content);
fclose($file);
}
}
我有403錯誤 「禁止接入」!我做錯了什麼?