I have uploaded files on server and I want to download on button click. But I did tried with below codes, it's working only on image files. Not on other extensions like pdf, xlsx, txt, docx and others. How should i do that to download all extensions.
Here is my View Code.
<a href="{base_url('CustomerInformDetailEditController/fileDownload/')}{$row->file_path}{$row->file_name}">Download</a>
Here is my controller Code.
function fileDownload(){
$this->load->helper('download');
$filename = urldecode($this->uri->segment(5));
$filepathName = file_get_contents(base_url(). $this->uri->segment(3) . "/" . $this->uri->segment(4) . "/" . $filename);
echo $filepathName;
force_download($filename, $filepathName);
}