public function download($f3, $args) { $filename = $args['filename']; $filename = setEncryptDecrption($filename, false); $file = DOCROOT . $f3->get("doc_folder_name") . "/" . "portfolio/" . basename($filename); /*if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/pdf'); header("Pragma: public"); header("Expires: 0"); header("Cache-Control:must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/download"); header("Content-Disposition: attachment; filename={$filename}"); header("Content-Transfer-Encoding: binary "); header('Content-Length: ' . filesize($file)); while(ob_get_level()) ob_end_clean(); flush(); readfile($file); die; }*/ // send() method returns FALSE if file doesn't exist if (!Web::instance()->send($file)) { // Generate an HTTP 404 $f3->error(404); } exit; }
private function readFolder($folder_path) { global $f3; $path = DOCROOT . $f3->get("doc_folder_name") . "/" . $folder_path . "/"; $out = array(); $files = scandir($path); foreach ($files as $key => $value) { if ($value == "." || $value == "..") { continue; } $out[] = array("original_name" => $value, "filename" => setEncryptDecrption($value), "extension" => (new SplFileInfo($value))->getExtension()); } return $out; }