CodeIgniter Forums
loading images in browser - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: loading images in browser (/showthread.php?tid=21222)



loading images in browser - El Forum - 08-03-2009

[eluser]Unknown[/eluser]
I can't load my images from my root directory ,what is the problem ?


loading images in browser - El Forum - 08-03-2009

[eluser]skunkbad[/eluser]
show some code, and we can probably help


loading images in browser - El Forum - 08-03-2009

[eluser]Unknown[/eluser]
<img src="&lt;?=base_url()?&gt;?images/2.jpg" border="0" />


loading images in browser - El Forum - 08-03-2009

[eluser]Zeeshan Rasool[/eluser]
I think there is an error in this code. You are using ( base_url()? )it like passing a param to a php page.

You should use ...

Code:
&lt;?=base_url()?&gt; images/2.jpg

OR (if you haven't any '/' in the end of baseURL ,then)

Code:
&lt;?=base_url()?&gt; / images/2.jpg



loading images in browser - El Forum - 08-03-2009

[eluser]skunkbad[/eluser]
you probably need to output a surrounding image tag.

Code:
&lt;?php
echo '<img src="' . base_url() . 'images/2.jpg" alt="whatever" />';

//unless you really meant to have that question mark between your base url and 'images'. and if that is the case then do this:

echo '<img src="' . base_url() . '?images/2.jpg" alt="whatever" />';

//this assumes you have an image directory called 'images' that is located at root.



loading images in browser - El Forum - 08-04-2009

[eluser]richthegeek[/eluser]
*drumroll*

Code:
&lt;?php echo site_url("/images/2.jpg"); ?&gt;

ta-da!


loading images in browser - El Forum - 08-04-2009

[eluser]wiredesignz[/eluser]
Rich are you drunk?

Code:
&lt;?php echo site_url("/images/2.jpg"); ?&gt;  //produces: http://domain.tld/index.php/images/2.jpg

Its not even an image tag or a link. Tongue


loading images in browser - El Forum - 08-04-2009

[eluser]richthegeek[/eluser]
lol, not drunk, just tired.

I always (always always always) have mod_rewrite going on so my site URL has no index.php in it.

And OP's question wasn't really about producing a tag, just a good URL.