Fuelphp休息PUT问题

时间:2013-11-29 03:41:37

标签: put fuelphp

框架 - fuelphp 1.7

我尝试将文件从服务器上传到另一个。

发送我使用curl。

$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错误“禁止访问!”。我做错了什么?

1 个答案:

答案 0 :(得分:0)

默认情况下,许多Web服务器只接受GET和POST,您需要启用PUT,DELETE和PATCH。也许这也是这种情况?