Open a existent pdf file using CI

[eluser]Thiago Luiz[/eluser]
Hi, my name is Thiago and I'm from Brazil. I'm trying to open a existent pdf file into a browser using CI but I had no success. Someone can help me?

It's just an ordinary 'a href=...'. I don't think CI has anything to do with the opening, that is dependent on how the browser is setup to handle links of that type.
But maybe you can explain in a little more detail what you are trying to accomplish?

Make sure in your htaccess file that the directory or file is excluded from being routed through codeigniters routing. Edit your htaccess file.

[eluser]Thiago Luiz[/eluser]
I am trying to open a view of the IC and putting href not just open the pdf file. I tried to upload through the controller, but without success.

This is an excerpt of the code view:

<table width="588" height="313" border="0" align="center" cellpadding="0" cellspacing="0">
<td height="215">
<p align="justify">
<a href="path/to/file.pdf" target="body">
- Some Text Here
<font color="#ff0000"><b>&nbsp;</b> </font>

And once again, I tried to construct a function trough and into this function, I tried to load pdf file but no success.

[eluser]Adi Setiawan[/eluser]
just like hostcord said, you may exclude path to pdf file for being route by CI in .htaccess

RewriteCond $1 !^(index\.php|pathtopdf)

[eluser]Thiago Luiz[/eluser]
Adi, I tried to do what you and hostcord said but I have no success.
Something that I tried was call a function of controller in href into the view and in the controller call $this->load->view('subfolder/file.pdf');

but this way appeared a error like this:

Warning: Unexpected character in input: '' (ASCII=1) state=1 in C:\ complete path on line 394

Parse error: syntax error, unexpected ':' in C:\ complete path on line 394

I don't understand this error because, the pdf file is like any pdf file that can be found on internet

[eluser]Adi Setiawan[/eluser]
not sure what you want, why you load pdf file as view file? could you explain what exactly do you want?
if you want to force user to download pdf file, you can use download helper
$data = file_get_contents("subfolder/file.pdf");
$name = 'file.pdf';
force_download($name, $data);

[eluser]Thiago Luiz[/eluser]
let me explain a little in details:
I have a menu where the stories are posted and some news may be a pdf file that is in a subdirectory.
Then I want to create a link to open the pdf file in web page using the CI.

[eluser]Adi Setiawan[/eluser]
then it's just as easy as create html link <a href="link/to/file.pdf">news in pdf</a>

[eluser]Thiago Luiz[/eluser]
this is the exact problem, this does not work

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.