Untitled

 avatar
unknown
plain_text
3 years ago
913 B
5
Indexable
public function downloadTemplate()
    {
        $_REQUEST['file'] = './Resource/dieutradanso.pdf';
        if (isset($_REQUEST["file"])) {
            $file = urldecode($_REQUEST["file"]); 
            $filepath = "" . $file;
            if (file_exists($filepath)) {
                header('Content-Description: File Transfer');
                header('Content-Type: application/pdf');
                header('Content-Disposition: attachment; filename="' . basename($filepath) . '"');
                header('Expires: 0');
                header('Cache-Control: must-revalidate');
                header('Pragma: public');
                header('Content-Length: ' . filesize($filepath));
                flush(); 
                readfile($filepath);
                die();
            } else {
                http_response_code(404);
                die();
            }
        }
    }
Editor is loading...