【发布时间】:2014-11-28 13:16:11
【问题描述】:
public function upload ($data = null) {
foreach ($data as $file) {
$filename = $file['name'];
$file_tmp_name = $file['tmp_name'];
$dir = WWW_ROOT.'img'.DS.'uploads';
$allowed = array('png', 'jpg', 'jpeg');
if (!in_array(substr(strrchr($filename, '.'),1) , $allowed)) {
throw new NotFoundException("Error Processing Request", 1);
}
elseif (is_uploaded_file($file_tmp_name)) {
$new_filename = DS.STring::uuid().'-'.$filename;
move_uploaded_file($file_tmp_name,$dir.$new_filename);
if ($this->Upload->save($this->request->data)) {
`$this->Session->setFlash('Data Saved!');
}
}
}
}
我得到了这个错误..
在非对象上调用成员函数 save()
我该如何解决这个问题?
【问题讨论】:
-
这个功能在哪里?在控制器内部?如果是,控制器的名称是什么?
-
它在组件文件夹里面.. UploadComponent.php
-
你试过我的答案了吗?