Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在codeigniter中显示图像_Php_.htaccess_Codeigniter_Xampp - Fatal编程技术网

Php 如何在codeigniter中显示图像

Php 如何在codeigniter中显示图像,php,.htaccess,codeigniter,xampp,Php,.htaccess,Codeigniter,Xampp,我想显示图像窗体视图 <img src="<?php echo base_url('images/login.jpg'); ?> " width="90" height="40" /> “width=“90”height=“40”/ 但它不起作用。 当我写作时 <img src="images/login.jpg " width="90" height="40" /> 它在浏览器中显示,但在本地主机中不显示 我的.htaccess中是否存在问题 &l

我想显示图像窗体视图

<img src="<?php echo base_url('images/login.jpg'); ?> " width="90" height="40" />
“width=“90”height=“40”/
但它不起作用。 当我写作时

<img src="images/login.jpg " width="90" height="40" />

它在浏览器中显示,但在本地主机中不显示

我的.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> 

重新启动发动机
重写基本/helloworld/
#禁用对有效目录/文件的重写
重写cond%{REQUEST_FILENAME}!-f
重写cond%{REQUEST_FILENAME}!-d
#将所有请求URL映射到特定的控制器方法
重写规则^(.*)$index.php?/{controller}/{method}/$1[L]
#如果我们没有安装mod_rewrite,所有404
#可以发送到index.php,一切正常。
#提交人:ElliotHaughin
ErrorDocument 404/index.php

如果您只想在htaccsess文件中不使用“index.php”进行访问,请任何人帮助我

<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> 
<img src="<?php echo base_url(); ?>images/login.jpg" width="90" height="40" />

重新启动发动机
重写基本/helloworld/
#禁用对有效目录/文件的重写
重写cond%{REQUEST_FILENAME}!-f
重写cond%{REQUEST_FILENAME}!-d
#将所有请求URL映射到特定的控制器方法
重写规则^(.*)$index.php?/$1[L]
#如果我们没有安装mod_rewrite,所有404
#可以发送到index.php,一切正常。
#提交人:ElliotHaughin
ErrorDocument 404/index.php
“图像”文件夹必须位于项目的根目录中。
我希望我的答案能帮助你:D

这个方法不管
.htaccess
文件和put
index.php

<img src="<?php echo base_url('index.php/images/login.jpg'); ?> " width="90" height="40" />
然后,您就可以在不使用
index.php的情况下访问

<img src="<?php echo base_url('images/login.jpg'); ?> " width="90" height="40" />
“width=“90”height=“40”/
你喜欢这样吗

<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> 
<img src="<?php echo base_url(); ?>images/login.jpg" width="90" height="40" />
你的形象应该是一个地方

application
images
    login.jpg
system
index.php

你有任何与广告相关的类名吗?? 如果是,浏览器的ad块扩展往往会隐藏图像,在我的项目中也会遇到类似的问题,那么只需为测试禁用扩展或更改类名即可


只是猜测而已。希望对你有帮助

不要忘记在控制器构造函数上导入url帮助器

function __construct()
{
    parent::__construct();
    $this->load->helper('url');
}

它怎么不起作用?它根本不显示?出现任何错误?通过inspect元素检查图像是否正在加载它正在加载但图像未显示因此您的路径可能是问题所在,在inspect元素中显示的路径是否正确?执行此操作时,它在inspect模式下工作,在LocalHost中显示但不显示我尝试了两种解决方案,但图像未显示删除它。保持empty@A.Nabil发生什么事了?我删除了它,但图像也没有displayed@A.Nabil只需检查图像是否没有JPG扩展而不是JPG。在linux系统中,case matters.view/myproject/images/login.jpg我从myprojectMy image In images文件夹中的Home_视图中加载了它,在views文件夹中您可以在view文件夹中加载图像,如果您按基本url将其存储在view文件夹中,我认为在这种情况下您必须使用静态url,例如:因为当您使用基本url时(“'images/login.jpg'”),图像src url是“http:localhost/images/login.jpg”,它必须位于根目录下的images文件夹中。我加载了帮助程序url,您应该以注释的形式提问。