EllisLab text mark
Advanced Search
Cannot display images in assets folder
Posted: 21 October 2011 01:17 AM
Joined: 2011-10-15
146 posts


I am using codeingniter 2.0.3

My folders are:


In my images folder I have an image called: calendar.jpg

I call this image in one of my view like this:

<img src="<?php echo base_url();?>assets/images/calendar.jpg" /> 

The image is not displayed.

When I go to the page source and try to go to the image I get the page not found.

My htaccess file:

RewriteEngine on
RewriteRule ^(.*)$ /orders/index.php/$1 [L] 

I want to use this image as the icon for the datepicker, and since the image is not displayed, I just put in a view to see if it is found.

So my first question is why can’t the image be found.
My second question is how will I add the image to the jquery datepicker code? Will I have to hard code the path like so:



Can someone help and tell me why the image is not found?

Thank you.

Posted: 21 October 2011 05:25 AM   [ # 1 ]   [ Rating: 0 ]
Joined: 2009-06-19
6707 posts
base href="<?php echo base_url();?>">

img src="assets/images/calendar.jpg" />

// Or load the HTML Helper and use CI img tag!

<?php echo img('assets/images/calendar.jpg');?> 



Certified State of CT Computer Programming Teacher.
Custom Designed Icons, eBook Covers Software Boxes. CD, DVD Etc. New iPhone® Tab Bar Icons and iPhone® Applications Icons.

Skype: insitfx

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

Input -> Controller | Processing -> Model | Output -> View

Posted: 21 October 2011 09:02 AM   [ # 2 ]   [ Rating: 0 ]
Joined: 2011-10-15
146 posts

Thank you, but none of the ways work.

I have added this in the template header:

<base href="<?php echo base_url(); ?>"

and then in my home view:

<img src="assets/images/calendar.jpg" /> 

Nothing displayed.

Then I deleted the base and added:

<?php $this->load->helper('html'); ?> 

and in my home view:

<?php echo img("assets/images/calendar.jpg"); ?> 

Nothing is displayed.

Posted: 21 October 2011 09:13 AM   [ # 3 ]   [ Rating: 0 ]
Joined: 2011-10-15
146 posts

Oh dear god, I just realized, the image was in the wrong folder.

Sorry, red face

Posted: 29 May 2012 01:04 AM   [ # 4 ]   [ Rating: 0 ]
Joined: 2012-05-29
1 posts

But it helped many others including me smile



Posted: 29 May 2012 03:35 AM   [ # 5 ]   [ Rating: 0 ]
Joined: 2011-10-15
146 posts

Great, now I don’t feel like such a big idiot lol