You can generate a file from a string of data on the fly.
You can load multiple helpers simultaneously by passing an array. helper(['download', 'url', 'form']); Use code with caution. Core Function: force_download() codeigniter 4 download helper
$path = WRITEPATH . 'uploads/report.pdf'; $data = file_get_contents($path); return force_download('user_report.pdf', $data); Use code with caution. The Modern Alternative: Response::download() You can generate a file from a string of data on the fly