I'm trying to download a file using force_download
in codeigniter.
I create an AJAX call like this
$.ajax({
type: 'POST'
, url: '<?php echo base_url('downloadPayroll'); ?>'
, data: { filename: filename }
});
And here is my controller
public function downloadPayroll() {
$filename = $this->input->post('filename');
$fileContents = file_get_contents(base_url('assets/uploads/'. $filename));
force_download($filePath, $fileContents);
}
I know I have the correct path and filename but it doesn't download anything.
What am I doing wrong because the documentation for Download Helper is very limited.