CodeIgniter - force_download() no output
This will work with you
$this->load->helper('download');$path = file_get_contents(base_url()."modulos/".$filename); // get file name$name = "sample_file.pdf"; // new name for your fileforce_download($name, $path); // start download`
Just a note to anyone else who may be having this problem: Make sure you have a file extension on the filename you supply for the first argument to force_download()
.
CodeIgniter uses this to set the MIME type, and it doesn't seem to work without.
Remove that echo $data."/".$filename;
It should be like this
$this->load->helper('download');$data = file_get_contents("modulos/".$filename); // Read the file's contentsforce_download($filename, $data);