Search code examples
codeigniterpdfmodel-view-controllercodeigniter-2

How to open a pdf file which is in views or controller folder in ci?


i have a pdf file in view folder and controller folder by the link i need to access it how to do this i have tried with following by am getting error like Access forbidden!

$path=base_url()."application/views/users/sample_pdf_report.pdf";
$path2="C:\xampp\htdocs\vacationgod\application\views\users\sample_pdf_report.pdf"
// OPTIONAL - PUT A LINK TO DOWNLOAD THE PDF YOU JUST CREATED
echo ("<a href='$path2'>Download Your PDF</a>");

i have tried both $path and $path2


Solution

  • You probably have a .htaccess file forbidding people to access files in those folders.

    You should create a res folder in your site root path and place your pdf file in that folder and link the file from there..

    Happy coding :)