[eluser]dawnerd[/eluser]
That's actually how I'm doing it now. Here's a snippet from my download controller:
Code:
function paid()
{
//Check if user is logged in
if(!$this->users->isLoggedIn())
{
echo "Not allowed.";
return false;
}
$requested_file = $this->uri->segment(3);
$query = $this->db->getwhere('downloads', array('id'=>$requested_file));
foreach ($query->result() as $row)
{
$file_data = read_file($this->rootdir."paid/".$row->name.".".$row->filetype);
$file_name = $row->name.".".$row->filetype;
}
force_download($file_name, $file_data);
}
The problem comes up when CI loads the file as a string to force the download. I really don't want the file to be within the public's reach. Right now it sits under the html folder.