I want to display image form view
<img src="<?php echo base_url('images/login.jpg'); ?> " width="90" height="40" />
But it doesn't work. When I write
<img src="images/login.jpg " width="90" height="40" />
It show in browser but not show in localhost
Does the problem in my .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /helloworld/
# Disable rewrite for valid directory/files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#map all request urls to a specific controller method
RewriteRule ^(.*)$ index.php?/{controller}/{method}/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
please anyone help me
If you just want access without "index.php" in your htaccsess file should be like this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /helloworld/
# Disable rewrite for valid directory/files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#map all request urls to a specific controller method
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
And the images folder must be in the root of your project. I hope my answer can help you :D
This method regardless of .htaccess
file and put index.php
:
<img src="<?php echo base_url('index.php/images/login.jpg'); ?> " width="90" height="40" />
But if you still want to use .htaccess
file then replace all codes .htaccess
file with this code:
RewriteEngine On
RewriteRule ^(application) - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Then you can access without index.php
<img src="<?php echo base_url('images/login.jpg'); ?> " width="90" height="40" />
Do like this
<img src="<?php echo base_url(); ?>images/login.jpg" width="90" height="40" />
as well as in config/config.php
$config['base_url'] = '';
and your image should be place one
application
images
login.jpg
system
index.php
Do you have any class name related with advertisement ?? if yes ad block extension of browsers tends to hide the images, faced similar problems in my project too just disable the extension for the test or change the class name.
Just a guess. Hope it helps you.
Don't forget to import url helper on your controller constructor.
function __construct()
{
parent::__construct();
$this->load->helper('url');
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.