CodeIgniter Forums
codeigniter image path. - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: codeigniter image path. (/thread-43596.html)

codeigniter image path. - El Forum - 07-17-2011

I am a codeignite newbie and tried to add an image in my file under view folder.

I add
<img src="../images/myImage.jpg"></img>
to my service_view.php. All I can see is a broken link of a small icon.

however, if I change my path to

<img src="../../user_guide/images/myImage.jpg"></img>
I can see the image.

My file system is as follow:

   view ->folder    (where service_view.php is located)
   images -> folder   (where myImage.jpg is located)

   images ->folder  ((where myImage.jpg is located))

Can anyone help me about this? Thanks a lot!

codeigniter image path. - El Forum - 07-17-2011

[eluser]Eric Barnes[/eluser]
You should really use the base_url or img helper to create absolute paths -
<img src="&lt;?php echo base_url(); ?&gt;images/myImage.jpg" />
&lt;?php echo img('images/myImage.jpg'); ?&gt;

By the way the image html tag doesn't have a closing tag.

codeigniter image path. - El Forum - 07-17-2011

Thanks a lot Eric!! Your link does help me a lot!