Cakephp 3:在实时服务器中编辑时出现禁止错误

Cakephp 3: Getting Forbidden error when going to edit in live server

此代码在本地服务器中运行良好,但在实时服务器中我收到禁止错误 403。如果我提到 form type = 'post' 它在服务器中运行。但文件没有上传。如果我使用 'type'=>'file' 然后得到 Forbidden 错误。这是我的表单代码

<?php 
     echo $this->Form->create($depositOption,['type'=>'file']); // type='post' is working but image not uploading 
     echo $this->Form->input('name');
     echo $this->Form->input('image_edit',['type'=>'file']);
     echo $this->Form->submit("Submit")
     echo $this->Form->end() 
?>

我的控制器代码像

if ($this->request->is(['patch', 'post', 'put'])) {
    if(!empty($this->request->data['image_edit']['name'])){
        // upload image code 
    }
}
$depositOption = $this->DepositOptions->patchEntity($depositOption, $this->request->data);
$this->DepositOptions->save($depositOption)

如何定义这个表格类型是文件类型也是post.

你试过吗?使用表单选项添加 enctype

<?= $this->Form->create($depositOption,['type'=>'post','enctype' => 'multipart/form-data']) ?>