Display PDF |
[eluser]InsiteFX[/eluser]
Try creating and assets directory in the root with index.php and add a directory for pdf files! The application directory has an .htaccess file that protects the directory. InsiteFX
[eluser]Clooner[/eluser]
[quote author="sbarow" date="1307477274"]Yip I do. Look this is the situation if I had to write an html website with a pdf in a folder then uploaded it to a server and went to view the file at say http://example.com/pdf_folder/brochure.pdf then the pdf would open in the normal PDF viewer for Safari, Chrome, Firefox etc. Thats all I want to be able to do but because codeigniter would read the "pdf_folder" as a function and "brochure.pdf" as a method obviously it does not display the file from the location http://example.com/pdf_folder/brochure.pdf[/quote] Do you use a htaccess rewrite?
[eluser]mr lister[/eluser]
Try creating a new route to allow dynamic content to be routed to your Controller / Function. In your routes file under the config folder, create something like: $route['pdf/:any'] = 'pdf/name_of_pdf_file'; This will route: Code: base_url().site/pdf/12345_brochure.pdf You can read about routing in the user guide. Example (Codeigniter v2): Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); If you have other functions in your 'pdf' controller, they now cannot be called - unless routed in the routes file - as anything after the base_url().site/pdf will be routed to the name_of_pdf_file() function. You can obtain the PDF file name utilising $this->uri->segment(2) if you like. Hope this helps.
[eluser]KBB[/eluser]
Hey! I don't know is there anybody watching this thread by now, but I got the same problem and finally have the solution. So basically InsiteFX's solution in #6 is good with a little modification: Code: header("Content-disposition: inline; filename=$file"); The "inline" tells the browser, that it should open the file, instead of downloading it. I hope it will help those who come across in the future. |
Welcome Guest, Not a member yet? Register Sign In |