此代码在本地服务器上工作正常,但在实时服务器中我收到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。
答案 0 :(得分:2)
<?= $this->Form->create($depositOption,['type'=>'post','enctype' => 'multipart/form-data']) ?>