我正在尝试在新托管中设置一个旧的cakePHP应用程序,突然间我在共享godaddy托管上遇到此错误。它在老托管中工作正常。我已经在CakePHP工作了2年,似乎并不明白为什么会这样。我使用以下上传插件cakephp-upload
Error: SQLSTATE[HY000]: General error: 1364 Field 'photo_dir' doesn't have a default value
SQL Query: INSERT INTO `prayag_cms`.`galleries` (`branch_id`, `name`, `album_id`, `display_photo`, `modified`, `created`) VALUES (0, 'Photo', 1, 'CpLMQ28WYAEOnow.jpg_large.jpg', '2016-12-06 10:17:14', '2016-12-06 10:17:14')
这是我的确认
public $actsAs = array(
'Containable',
'Upload.Upload' => array(
'display_photo' => array(
'fields' => array(
'dir' => 'photo_dir'
),
'thumbnailSizes' => array(
'small' => '250x250',
),
'thumbnailMethod' => 'php',
'path' => '{ROOT}webroot{DS}img{DS}{model}{DS}',
),
)
);
控制器:
public function admin_add() {
if ($this->request->is('post')) {
$this->Gallery->create();
if ($this->Gallery->save($this->request->data)) {
$this->Session->setFlash(__('The gallery has been saved.'), 'admin/flash_success');
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The gallery could not be saved. Please, try again.'), 'admin/flash_error');
}
}
$branches = $this->Gallery->Branch->find('list');
$albums = $this->Gallery->Album->find('list');
$this->set(compact('branches', 'albums'));
}
答案 0 :(得分:1)
可能正在发生文件夹不存在(webroot / img / users [model])或没有足够的权限来创建新文件夹或访问文件夹。
photo_dir
分配为空希望你的问题能够得到解决