[eluser]vitoco[/eluser]
First of all, was a bad copy paste...
1.- force the download on the the index method
Code:
<?php
// THIS WORK IF YOU CALL http://domain/download/[index]
class Download extends Controller {
function index()
{
$data = file_get_contents(”../../filename.pdf”); // Read the file’s contents
$name = ‘filename.pdf’;
//
force_download($name, $data);
}
}
?>
2.- force the download on the the get_pdf method, that will be called in a view
Code:
<?php
// THIS WORK IF YOU CALL http://domain/download/get_pdf/
class Download extends Controller {
// shows a link to download the pdf
function index()
{
echo base_url().'/download/get_pdf';
}
function get_pdf()
{
$data = file_get_contents(”../../filename.pdf”); // Read the file’s contents
$name = ‘filename.pdf’;
//
force_download($name, $data);
}
}
?>
Saludos