CodeIgniter Forums
image problems - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: image problems (/thread-11819.html)



image problems - El Forum - 09-24-2008

[eluser]Unknown[/eluser]
Okay, I am having a problem in displaying an image. I have created an images folder and directed the html helper to that file to display my image. However, there is no image displayed. I viewed the document source, and the address being generated by the html helper is correct, but there is no image. Can anyone tell me why that would happen? Also, I have read several people talking about an .htaccess file, but I did not create an htaccess file, nor do I even know where it is. Help!!!


image problems - El Forum - 09-24-2008

[eluser]Sumon[/eluser]
.htaccess file located in your root directory.
Do you copy and paste image address in your browser and get the image correctly? There are two other ways by which you can view image file.

Firstly try to use relative path instead of absolute. Relative path will start from index.php(located in root of CI).

Secondly try to use image path using DOCUMENT_ROOT.Say your document root is var/www/vhosts/yoursite.com/httpdocs and your image folder from root is images/mem_photo/ then try to generate path using helper as concat these paths. finally your image file path is as:
Code:
$img_loc='var/www/vhosts/yoursite.com/httpdocs'.'/images/mem_photo/'.$img_file_name;
echo $img_loc; // for test



image problems - El Forum - 03-02-2009

[eluser]alejandra[/eluser]
I'm having problems displaying images in codeigniter. I'm developing a new app for a website and I'm using codeignier. The codeigniter framework is install in a subdirectory and have place a view under the view folder and images are under the same folder in a folder called images.

I use a controller to load the view and when load the controller the view is display but no pictures display.

here is how I load the view:

Code:
$this->load->view('template.php');

and here is how I use the image tag in my view:

Code:
<img height="95" alt="" width="799" border="0" src="images/header.jpg" />

Maybe is something simple but I just don't see it Sad


image problems - El Forum - 03-02-2009

[eluser]pistolPete[/eluser]
So your directory structure looks like this?
Code:
subdir
    system
        application
            controllers
            models
            views
                template.php
                images

Then you have to use an appopriate path in your view:
Code:
<img height="95" alt="" width="799" border="0" src="/subdir/system/application/views/images/header.jpg" />

Use Firebug to see which image path is actually requested when you load the page.


image problems - El Forum - 03-02-2009

[eluser]alejandra[/eluser]
I have change it and it still does not work...
Code:
<img height="95" alt="" width="799" border="0" src="/campaign/sponsor/application/views/images/header.jpg" />

I also change all images to a folder called assets under the subdirectory:

Code:
<img height="95" alt="" width="799" border="0" src="/campaign/assets/images/header.jpg" />

I have done codeigniter before and did not have this image problem, maybe something is rendering differently?

Thanks firebug tip Smile


image problems - El Forum - 03-02-2009

[eluser]alejandra[/eluser]
This is fixed thank for the help I was missing subfolder the right path will be:
Code:
<img height="95" alt="" width="799" border="0" src="/campaign/sponsor/assets/images/header.jpg" />

Embarrassed but happy it worked Smile