Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codeigniter image path

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:

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

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

Can anyone help me about this? Thanks a lot!

like image 710
FlyingCat Avatar asked Jul 17 '11 21:07

FlyingCat


2 Answers

I would suggest storing images in an images folder at the same level as the application folder, instead of trying to mix both PHP code and resources underneath application. Then just link to it like you did to the user guide:

<img src="../../images/myImage.jpg" />
like image 181
Justin Ethier Avatar answered Sep 22 '22 12:09

Justin Ethier


I know more than year has passed since the question was asked but for anyone who comes looking in future, Here is my solution....

I've tried this created a folder images at same level as that of application, in main index.php added a line before last require_once statement.

define('IMAGE_PATH', APPPATH.'../images/');

and used IMAGE_PATH anywhere I wanted to display images.

Hope this helps

like image 24
Rohan210 Avatar answered Sep 18 '22 12:09

Rohan210