public function upload($file, $module, $moduleId) { $upload = new fileupload(); $path = $file['file']['name']; $ext = pathinfo($path, PATHINFO_EXTENSION); $newPath = $upload->getPath() . $module . '/'; $upload->setPath($newPath); $upload->initFile($file['file']); $return = false; if ($upload->error == '') { $newname = md5($_SESSION['userdata']['id'] . time()); $upload->renameFile($newname); if ($upload->upload() === true) { $values = array('encName' => $newname, 'realName' => str_replace('.' . $ext, '', $file['file']['name']), 'extension' => $ext, 'moduleId' => $moduleId, 'userId' => $_SESSION['userdata']['id']); $return = $this->addFile($values, $module); } } return $return; }