PDFs are not downloaded correctly in the Codeigniter

0

I'm using Grocery Crud, I have a field of type text and when I add or edit a ckeditor comes out, which is perfect. My problem is when I visualize these data, the images, texts, I have no problems, but if I put in to download a pdf or a .rar, the address that I get is the one that I put in the ckeditor, but behind all the address of the page.

Example:

PDF address: assets/pdf/test.pdf

Address in the view: localhost/codeigniter/index.php/admin/text_page/assets/pdf/test.pdf

Additional information

With grocery crud I save the data in the Database, (IN ONE FIELD), that is, in this field is everything I want to show, text, image, including the PDF, when I go to the view where I show this field, the images look good but the PDF url does not.

I need to leave neither the controller nor the function. Thanks in advance.

    
asked by Mary 21.04.2017 в 15:54
source

1 answer

0

Good morning. You can use the base_url(); in your codeigniter application in the config/ folder in the config.php file, look for the variable $config['base_url'] and place the address of your application:

$config['base_url']='localhost/codeigniter/';

And in your controller you call your method by base_url like this:

base_url('admin/text_page/assets/pdf/test.pdf');

Now you can also handle an htaccess file like this:

# Customized error messages.
ErrorDocument 404 /index.php

# Set the default handler.
DirectoryIndex index.php

# Various rewrite rules.

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond $1 !^(index\.php|images|robots\.txt)
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /codeigniter/index.php/$1 [L]

</IfModule>  
<IfModule mod_headers.c>
  <FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|css)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>
php_value upload_max_filesize 30M
php_value post_max_size 30M
php_value max_execution_time 1000
php_value max_input_time 1000
    
answered by 21.04.2017 в 16:58