怎么卷曲在PHP使用更新?

时间:2015-07-01 06:28:51

标签: php curl

通过put方法发送数据以进行更新

{{ Form::model($books, array('route' => array('package.update', $books->id), 'method' => 'put', 'files'=>'true')) }}

和我的控制器

enter code here

强文

$ch = curl_init();
$file = $data['file'];  
$data['title'] = $data['course_name'];
if (isset($data['file']))
    $data['file'] = new CURLFile($_FILES['file']['tmp_name'], 'application/pdf',$_FILES['file']['name']);
$data['resource_id'] = $book->urnid;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);  
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
print_r(curl_error($ch));
curl_close($ch);

它给出了

{"detail":"Method 'PUT' not allowed."}

但是也尝试通过post和patch方法仍然会给出相同的错误。

0 个答案:

没有答案