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!');
}
}
}
}
And I got this error..
Call to a member function save() on a non-object
How to can I fix this?