[eluser]deltajam[/eluser]
I just don't get it. Sometimes it works, sometimes it doesn't. This Force Download thing is starting to drive me crazy.
Why oh why can't I get it to work like a right-click on a link? If I choose to 'Save link as ...' the download dialog box immediately comes up. Where as, if I choose to use 'Force Download', sometimes it takes 5mins for the screen to come up, and sometimes it doesn't come up at all, and I get blank screen that says 'Done'.
I need a real solution here. How do I get Force Download to work like 'Save link as..'
I'm at the end of my rope here.
Code:
function get( $file_hash )
{
if ($this->session->userdata('logged_in') != TRUE) {
$this->session->set_userdata('whereis_login','downloads/get/' . $file_hash );
redirect('login/', 'refresh');
}
else
{
$query = $this->db->query("SELECT * FROM download_hash WHERE file_hash ='$file_hash' ");
if ($query->num_rows() > 0)
{
$row = $query->row();
$name = $row->file_name;
$user_id = $row->user_id;
$download_id = $row->download_id;
$file_type_id = $row->type_id;
$query2 = $this->db->query("SELECT name FROM download_type WHERE type_id ='$file_type_id' ");
$row2 = $query2->row();
$folder_name = $row2->name;
if( $this->session->userdata('info_id') != $user_id )
{
echo "You have not purchased this file.<p>";
echo "Please login and " . anchor('downloads/' . $download_id , 'click here') . " to purchase.";
}
else
{
$data = file_get_contents( base_url() . "media/downloads" . $folder_name . $name );
force_download( $name, $data );
}
}
}
}