Welcome Guest, Not a member yet? Register   Sign In
Image folder is inaccessible!!
#1

[eluser]Unknown[/eluser]
I have created assets folder in codeigniter now my directory structure is as follows:



-application
-system
-assets
--images
---bg.jpg

Then I created a view `main_chat_app.php`

Code:
<html>

    <body>
    
    
     <img src="&lt;?php echo base_url('assets/images/bg.jpg');?&gt;"/>
     &lt;?php echo img('assets/images/bg.jpg'); ?&gt;
    
    &lt;/body&gt;
    
    &lt;/html&gt;
then loaded view in following `chat` controller

Code:
&lt;?php
    Class Chat extends CI_Controller
    {
     public function __construct()
     {
      parent::__construct();
     }
    
     public function index()
     {
    
      $this->load->view('main_chat_app');
     }
    
    }
    
    
    
    ?&gt;
In my `config.php`

Quote:$config['base_url']='http://localhost/127.0.0.1/CodeIgniter_2.1.4/index.php';
On my computer `port 80` was busy so I had to change it to `7777` in `httpd.config`
with these settings I usually access `chat` controller as mentioned below.

Quote:http://localhost/127.0.0.1:7777/CodeIgni.../index.php
(see I have to add `7777`)
Do I need to specify `7777` in the `base url` too in `config.php`

but despite of doing all this, images are still inaccessible.
#2

[eluser]CroNiX[/eluser]
base_url should NOT contain index.php. It is a location, not a file. index.php belongs in the "index_page" setting only.

Otherwise when you use base_url() and img() it will tack on index.php to the url because it's in your base_url (which is where it gets that value), which obviously doesn't work.




Theme © iAndrew 2016 - Forum software by © MyBB