Cakephp 3:在实时服务器中进行编辑时出现Forbidden错误

时间:2016-12-21 10:37:26

标签: cakephp cakephp-3.0 cakephp-3.x

此代码在本地服务器上工作正常,但在实时服务器中我收到Forbidden错误403.如果我提到表单类型=' post'它在服务器上工作。但文件没有上传。如果我使用'键入' =>' file'然后得到禁止错误。这是我的表单代码

<?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。

1 个答案:

答案 0 :(得分:2)

你尝试过这个吗?使用表单选项

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