0
我是cakephp的新手,我有一個上傳表單並希望將所有使用POST的數據傳遞給控制器和模型,以便將其保存到數據庫。到目前爲止,沒有發生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 {}
?>