![]() |
Unable to link images - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Unable to link images (/showthread.php?tid=20547) Pages:
1
2
|
Unable to link images - El Forum - 07-14-2009 [eluser]sirfak[/eluser] Hello, My project set up is as follows: |_______________/public_html | __index.php | __/Content | __/images | __/CSS | |______________/system | | |_____________/application My domain name (www.xyz.com which I have set as base_url)is pointing to index.php in /public_html file Now can u tell me how should I link my images folder? Thanks sirfak Unable to link images - El Forum - 07-14-2009 [eluser]Evil Wizard[/eluser] From your current layout your images folder would be at http://www.xyz.com/Content/images/ so in you views you could use Code: <img src="<?=base_url;?>Content/images/image1.jpg" alt="my image" /> Unable to link images - El Forum - 07-14-2009 [eluser]sirfak[/eluser] Hi I am getting following error Message: Use of undefined constant base_url - assumed 'base_url' Filename: views/index.php Line Number: 50 Unable to link images - El Forum - 07-14-2009 [eluser]sl3dg3hamm3r[/eluser] it is a function: base_url() ... and u need to load the url-helper to make it work. Unable to link images - El Forum - 07-14-2009 [eluser]sirfak[/eluser] Thanks dude. Considering the above said set up in the first message. CodeIgniter | |_______________/public_html | __index.php | __/Content | __/images | __/CSS | |______________/system | | |_____________/application /views welcome1.php welcome2.php Now in my welcome1.php I have a link <a href="welcome2.php">to 2nd page</a> But when i click this I am not going to welcome2.php If i do echo base_url(); I get http://localhost/CodeIgniter/public_html/ thanks Unable to link images - El Forum - 07-14-2009 [eluser]Iván Argulo[/eluser] Could you show us your base_url config? It's at application/config/config.php, it's something like $config['base_url']. Maybe your param there is not properly configured... Unable to link images - El Forum - 07-14-2009 [eluser]sirfak[/eluser] Hi this is my base_url config $config['base_url']= "http://localhost/CodeIgniter/public_html"; Thanks sirfak Unable to link images - El Forum - 07-14-2009 [eluser]Iván Argulo[/eluser] Try using site_url() instead base_url(): Code: <a href="<?php echo site_url('welcome2'); ?>">Link</a> Could you tell us how are you writing the anchor? Unable to link images - El Forum - 07-14-2009 [eluser]garymardell[/eluser] base url in config file is meant to have a trailing forward slash i believe. Unable to link images - El Forum - 07-14-2009 [eluser]sirfak[/eluser] Hi after using site_url() instead of bse_url() still i am not getting the file in view folder With site_url(); it is coming as http://localhost/CodeIgniter/public_html/index.php/welcome2.php in browser |