Welcome Guest, Not a member yet? Register   Sign In
Where to place resources?

This may sound dumb but I can't work out where I should place my images and stylesheets so that I can access them from the views file when the page is executed and complied.
Any help is appreciated and thanks in advance.

I put them in an asset folder at the same level of the index.php file. I then put in a <base href="base.com"/> to get all relative urls right and stuff.

[eluser]Armchair Samurai[/eluser]
I set up my apps like this, keeping images and stylesheets in the docroot like a normal webpage:
|- app
|- codeigniter1.5.4
|- httpdocs
|   |
|   |- css
|   |
|   |- images
|   |
|   |- index.php
When you want to access a stylesheet or image, just call base_url().
<!-- In a view -->
<link href="<?=base_url();?>css/your_stylesheet.css" rel="stylesheet" type~"text/css" />

<img src="&lt;?=base_url();?&gt;images/your_image.png" alt="" />

I wrote an article on this a while ago called . If you want to remove index.php from your URI with routing and also use a .htaccess file, things get a little tricky and my article explains how to remove index.php while still allowing access to your images, css, javascript folders, etc..

Build Your First Web2.0 App with PHP, Ajax, and CodeIgniter

[eluser]Michael Wales[/eluser]
I create the following folders at the root level:

I then link to those items using base_url() so I have absolute links, you could always just use a relative from root.

<img src="&lt;?= base_url(); ?&gt;images/home.png" />

<img src="/images/home.png" />

Theme © iAndrew 2016 - Forum software by © MyBB