Why can't find the picture 为什么找不到图片? |
[eluser]DogWin[/eluser]
hello all My code is "img('images/sinatra_beach_2.jpg')",but I don't see this picture. Who can help me and excuse,Thanks! by Dogwin 我的代码为img('images/sinatra_beach_2.jpg');但是我看不到这个图片,谁能解释下!
[eluser]khagendra[/eluser]
Within <img> tag try like this, it will work Code: <img src="<?php echo base_url().'images/sinatra_beach_2.jpg';?>" width="" height="" /> Note: To use base_url(), the url helper should be loaded in ur controller or it should be loaded globally in config/autoload.php 1. In controller u can load like this Code: class ContrllerName extends Controller Code: $autoload['helper'] = array('url'); ---> It wiil be better if you load url helper from config/autoload.php as it is loaded globally and you not need to load in each controller, it will be loaded automatically.
[eluser]DogWin[/eluser]
thank u for ur help.But it does not work! My controller main.php class Main extends Controller{ function Main(){ parent::Controller(); $this->load->helper(array('url','form','cookie','html')); $this->load->library(array('form_validation','session')); } function pro_info(){ $this->load->view("main/pro_info"); } } My views pro_info.php <img src="<?php echo base_url().'images/sinatra_beach_2.jpg';?>" width="50%" height="50%" /> The picture url is "http://zrof/images/sinatra_beach_2.jpg";
[eluser]czetsuya[/eluser]
Hi, Kindly check your base_url definition in cnofig/config.php and see if it points to: http://zrof/. Also images folder should be located in the root directory where you unpacked codeigniter. For example: +root +application +system . . .images Regards, czetsuya
[eluser]DogWin[/eluser]
Thanks $config['base_url'] = "http://zrof/"; images folder is located in the root directory but It still does not work!
[eluser]czetsuya[/eluser]
Hi, Can you try to view the source of your page and see the actual link. To view source on browser: Click View->Page Source. Then copy the link and paste it to the url - see if it works. Regards, czetsuya
[eluser]khagendra[/eluser]
1. Check the base url in the config file. it should be like this Code: $config['base_url']= "http://example.com/"; // end with a trailing slash 2. The next thing the images folder should be in the location of index.php file of codeigniter.
[eluser]DogWin[/eluser]
the link is "http://zrof/images/sinatra_beach_2.jpg" It does not work. I have a .htaccess file which is located in the root directory The code is: RewriteEngine on RewriteRule ^$ /index.php [L] RewriteCond $1 !^(index\.php|img|css|js|robots\.txt|favicon\.ico|update\.php|install\.php) RewriteRule ^(.*)$ /index.php/$1 [L] my ci config.php $config['base_url'] = "http://zrof/"; $config['index_page'] = ""; $config['uri_protocol'] = "PATH_INFO"; Do these affect the normal running? 这些影响正常运行吗?
[eluser]DogWin[/eluser]
Thanks everyone,I found the problem. Change the code "RewriteCond $1 !^(index\.php|img|css|js|robots\.txt|favicon\.ico|update\.php|install\.php)" to "RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico|update\.php|install\.php)" It was the url rewrite problem.
[eluser]John_Betong[/eluser]
Whois ZROF Quote:Information Updated: Wed, 28 Oct 2009 04:52:00 UTC |
Welcome Guest, Not a member yet? Register Sign In |