/** * method to move an uploaded file from the tmp dir to a more permanent home * @param string $dir The destination directory * @param string $name An optional name to call the file * @return bool */ function save($dir, $name = null) { if ($this->getError() == UPLOAD_ERR_OK) { $destination = sprintf("%s/%s", rtimr($dir, "/ "), $name ?: $this->getName()); if (!is_dir($destination)) { throw new Exceptions\UploadErrNoDestDir(); } return move_uploaded_file($this->getTmpName(), $destination); } return false; }
/** * This function will return a view content if it can find one * * @throws Exception */ public function get_view_content() { $output = []; try { if (isset($_REQUEST['view']) && ($view = trim($_REQUEST['view'])) !== '') { $view = rtimr(ltrim($view, "/"), "/"); if (!file_exists(APPPATH . 'views/' . $view . '.php')) { throw new Exception('Invalid view provided. View does not exist'); } $viewParam = isset($_REQUEST['view_param']) && is_array($_REQUEST['view_param']) ? $_REQUEST['view_param'] : array(); $output['html'] = $this->load->view($view, $viewParam, true); $output['status'] = true; $output['data'] = array(); } else { throw new Exception('A View must be provided for loading'); } } catch (Exception $ex) { $output['status'] = false; $output['message'] = $ex->getMessage(); } ajaxResponse($output); }