![]() |
Problem in loading images in my web page - 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: Problem in loading images in my web page (/showthread.php?tid=33326) |
Problem in loading images in my web page - El Forum - 08-23-2010 [eluser]oldrock[/eluser] Hi.., i m just to starting to program my site using code igniter. i have done the following steps 1. created the index page code in the views folder. 2. i loaded the index page from the controller with the code $this->load->view('index'); 3. i got the index page displayed in the browser but the images i have included in my code from the images folder is not getting displayed. help me please with your solutions, it would be greatful for me Problem in loading images in my web page - El Forum - 08-23-2010 [eluser]cchi[/eluser] echo the base_url() then point to the folder wer ur images are place.. Problem in loading images in my web page - El Forum - 08-23-2010 [eluser]Met[/eluser] or add <base href="<?php echo site_url();?>" /> then you can use relative links to your media, i.e using this "base" href, <img src="assets/images/foo.jpg" /> is the same as <img src="http://www.mysite.com/assets/images/foo.jpg" /> but much more portable Problem in loading images in my web page - El Forum - 08-23-2010 [eluser]oldrock[/eluser] Thanks for your reply can u please let me know in which file i have to add those settings. i got following error while using the img function Fatal error: Call to undefined function img() in /opt/lampp/htdocs/gowtham1/CodeIgniter_1.7.2/system/application/views/test4.php on line 6 Thanks in advance Problem in loading images in my web page - El Forum - 08-23-2010 [eluser]Met[/eluser] the <base href /> code goes in your views - inbetween html "<head></head>" tags. you also have to load the HTML helper to use img - $this->load->helper('html'); in your controller. Problem in loading images in my web page - El Forum - 08-23-2010 [eluser]cchi[/eluser] $autoload['helper'] = array('url'); >>enable this to you autoload page.. Problem in loading images in my web page - El Forum - 10-01-2010 [eluser]portgaz[/eluser] maybe it has something to do with your .htaccess file.. just add the the name of the image folder. :lol: hope it helps! |