Welcome Guest, Not a member yet? Register   Sign In
Why can't find the picture 为什么找不到图片?
#1

[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');但是我看不到这个图片,谁能解释下!
#2

[eluser]khagendra[/eluser]
Within <img> tag try like this, it will work
Code:
<img src="&lt;?php echo base_url().'images/sinatra_beach_2.jpg';?&gt;" 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
{
   function ControllerName()
   {
     parent::Controller();
  
     $this->load->helper('url');
   }
}
2. OR open autoload.php in system\application\config folder and add url in $autoload['helper'] array.
Code:
$autoload['helper'] = array('url');

---&gt; 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.
#3

[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="&lt;?php echo base_url().'images/sinatra_beach_2.jpg';?&gt;" width="50%" height="50%" />

The picture url is "http://zrof/images/sinatra_beach_2.jpg";
#4

[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
#5

[eluser]DogWin[/eluser]
Thanks

$config['base_url'] = "http://zrof/";
images folder is located in the root directory
but It still does not work!
#6

[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
#7

[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.
#8

[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?
这些影响正常运行吗?
#9

[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.
#10

[eluser]John_Betong[/eluser]
&nbsp;
Whois ZROF
&nbsp;

Quote:Information Updated: Wed, 28 Oct 2009 04:52:00 UTC

ZROF.COM SITE INFORMATION

IP: 72.167.131.208
IP Location: Scottsdale, United States
Website Status: inactive
&nbsp;
&nbsp;
&nbsp;




Theme © iAndrew 2016 - Forum software by © MyBB