• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help using force_download...

Hi everybody,
I am having trouble using force_download.
I have following code:

function download(){

$id = $this->input->get_post('download', TRUE);


$data['freebies'] = $this->get_freebies->downloadselect($id);


function downloadselect($id){

$query =  $this->db->get_where('freebies',array('freebiesid' => $id));

if( $query->num_rows() > 0 )

       $row = $query->row();
       $name = $row->name;
       $data = file_get_contents(realpath('freebies_files/'.$name.'.jpg'));    
       force_download($name, $data);

I use an ajax-request to the controller using mootools(Request.HTML) which works fine when trying to delete files.

But the download does not Sad
Nothing happens at all.

Any hints?


hint number 1: [SOLVED] AJAX + force_download

hint number 2: there is a searchbox in the upper right Wink

Yup, the headers would be an issue.

You could use JS to redirect the user to another page (possibly with target="_blank") that will set the header and force the download but keep popup blockers in mind (a link would probably work just fine).

Hi guys,
sorry, but I it was late last night so I must have missed the thread.
I always search for solutions first before I post.
Thanks for your help.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.