Cakephp 3:为

时间:2016-09-23 17:01:22

标签: cakephp cakephp-3.x

我使用的是cakephp 3.3.2版本和5.6 php版本。

我的编辑操作看起来像

public function edit($id = null) {
        $country = $this->Countries->get($id, [
                'contain' => []
            ]);
        if ($this->request->is(['patch', 'post', 'put'])) {
            $country = $this->Countries->patchEntity($country, $this->request->data);
            if ($this->Countries->save($country)) {
                $this->Flash->success(__('The country has been saved.'));

                return $this->redirect(['action' => 'index']);
            } else {
                $this->Flash->error(__('The country could not be saved. Please, try again.'));
            }
        }
        $this->set(compact('country'));
        $this->set('_serialize', ['country']);
    }

此代码在localhost中工作正常,但在我的真实主机(使用共享主机)中,当我要编辑某些内容时,它会给我403 Forbidden错误。然后我用邮递员检查。然后我看到它在get和post上运行正常,但是给了403 Forbidden错误。在php或cakephp中有任何额外的设置可以解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

你说它正在使用localhost所以它可能是服务器问题.. 检查这个批准的答案 - Why does my web server software disallow PUT and DELETE requests?回答