我对 cakephp 很陌生,我有一个上传表单,并且想使用 POST 将所有数据传递给控制器和模型,以便它保存到数据库中。到目前为止,没有发生 cakephp 错误,但没有传递数据。
控制器代码:
<?php class Controller extends AppController {
public function add() {
if ($this->request->is('post')) {
$this->File->create();
if ($this->File->save($this->request->data)) {
$this->Session->setFlash(__('Your file has been liberated :)'));
$this->redirect($this->referer());
} else {
$this->Session->setFlash(__('Something went wrong!'));
}
}
}
}?>
查看代码:
<?php echo $this->Form->create('File'); ?>
<input type="uploader" name="selected-file" style="visibility: hidden;"/>
<?php echo $this->Form->end('Finish'); ?>
型号代码:
<?php class File extends AppModel {}
?>