Welcome Guest, Not a member yet? Register   Sign In
force_download on a link
#1

[eluser]Wonder Woman[/eluser]
Hi there,

I want to force a file to download when a user clicks on a link or a button...I have tried this with no such luck.

Can you help me? I currently have the following code...

view:
Code:
echo anchor(base_url().'admin/data/download/'.$record['file_name'], 'Download');

controller:

Code:
function download() {
   $this->load->helper('download');        
   $data = file_get_contents('./uploads/data/'.$this->uri->segment(4));
   $name = $this->uri->segment(4);
   force_download($name, $data);
   $this->load->view('admin/data/index');
}

Many thanks!




Theme © iAndrew 2016 - Forum software by © MyBB