function get_file($f3) { $hash_id = $f3->get("PARAMS.hash_id"); $id = Base56::decode($hash_id); $file = PFH_File_model::get($id); $filename = $file->filename; $filetype = $file->filetype; $md5 = $file->md5; //$filepath = PFH_MD5::get_file_path($f3, $md5); //$filepath = PFH_ZIP::read($f3, $md5); //$filepath = PFH_MD5::get_file_path($f3, $md5); $filepath = PFH_Archive::read($f3, $md5, $filename); $action = "download"; PFH_Log_model::create_log($f3, $file, $action); $force_download = FALSE; PFH_File_helper::download_contents($filepath, $filetype, $filename, $force_download); }
public function get_link($f3) { // 要設定這個header,才能做iframe header('X-Frame-Options: '); if ($f3->exists($this->session_error_key)) { //throw new Exception($f3->get($this->session_error_key)); $f3->set("json", $f3->get($this->session_error_key)); $template = new Template_json(); echo $template->render("callback.js", 'text/javascript'); return; } if ($f3->exists($this->session_key) === FALSE) { throw new Exception("no file"); //$f3->reroute("/"); //return $this; } $id = $f3->get($this->session_key); //echo $id; $bean = PFH_File_model::get_by_id($id); $result = PFH_File_model::get_link($f3, $bean); //$json = json_encode($result); $f3->set("json", $result); //echo $result; //return; $template = new Template_json(); echo $template->render("callback.js", 'text/javascript'); //echo $template->render("callback.js"); }