Welcome Guest, Not a member yet? Register   Sign In
Need help using force_download...
#1

[eluser]BobbyB[/eluser]
Hi everybody,
I am having trouble using force_download.
I have following code:

Code:
//Controller:
function download(){

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

$this->load->model('get_freebies');

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

}

//Model:
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?

Cheers&Thanks;
#2

[eluser]narkaT[/eluser]
hint number 1: [SOLVED] AJAX + force_download

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

[eluser]uptime[/eluser]
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).
#4

[eluser]BobbyB[/eluser]
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.




Theme © iAndrew 2016 - Forum software by © MyBB