【发布时间】:2014-04-07 15:40:34
【问题描述】:
我正在尝试在 ajax 调用期间上传图片。为此,我使用了一个插件来创建缩略图。但它也没有插入任何数据和缩略图。
我正在提供我的插件链接以及控制器代码和模型:
https://github.com/josegonzalez/cakephp-upload
$club_id = $this->request->data['Photo']['club_id'];
$id = $this->Auth->user();
$this->request->data['Photo']['user_id'] = $id["id"];
$this->request->data['Photo']['club_id'] = $club_id;
$this->request->data['Photo']['photo_type'] = "club";
$this->request->data['Photo']['profile_picture'] = "no";
$this->Photo->save($this->request->data);
和型号代码:
public $actsAs = array(
'Upload.Upload' => array(
'picture' => array(
'path' => '{ROOT}webroot{DS}img{DS}{model}{DS}{field}{DS}',
'fields' => array(
'dir' => 'picture_dir'
),
'thumbnailSizes' => array(
'thumb' => '100x100'
), 'thumbnailMethod' => 'php'
)
)
);
我的视图文件是:
$this->Form->create($id, array('type' => 'file', "id" => "multiform"));
$this->Form->input('picture', array('type' => 'file'));
$this->Form->button('Upload', array('type' => 'submit', "id" => "club_upload"));
$this->Form->end();
它不是在数据库中创建缩略图和数据。我坚持下去,任何想法都会帮助我。
【问题讨论】:
-
遇到任何错误(错误/调试日志)?上传没有ajax的图片,有什么帮助吗?因为通过 ajax 上传图片需要的代码与标准 POST 请求有点不同:)
-
不,我没有收到任何错误!
标签: cakephp