php CodeIgniter:无法加载请求的文件:

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10648752/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 22:42:51  来源:igfitidea点击:

CodeIgniter : Unable to load the requested file:

phpcodeigniterweb-hosting

提问by Carl Michaels

Hi I'm just new in codeigniter. My website works locally, but when I uploaded it, I got this error:

嗨,我是 codeigniter 的新手。我的网站在本地工作,但是当我上传它时,出现以下错误:

An Error Was Encountered Unable to load the requested file: home\home_view.php

遇到错误无法加载请求的文件:home\home_view.php

Here is my controller:

这是我的控制器:

<?php
class home extends CI_Controller{

function index(){

  $data=array();
  if($query=$this->home_model->get_dynamic_main_menu())
  {
  $data[‘main_menu'] = $query;
  }

  $this->load->view(‘home\home_view',$data);
}


}

Thanks!

谢谢!

回答by Laurence

try

尝试

$this->load->view('home/home_view',$data);

(and note the " ' " not the " ‘ " that you used)

(并注意“ ' ”而不是您使用的“ ' ”)

回答by Najum Hussain

File names are case sensitive - please check your file name. it should be in same case in view folder

文件名区分大小写 - 请检查您的文件名。在视图文件夹中应该是相同的情况

回答by Hafiz Shehbaz Ali

I error occor. When you are trying to access a file which is not in the director. Carefully check path in the view

我出错了。当您尝试访问不在 Director 中的文件时。仔细检查视图中的路径

 $this->load->view('path');

default root path of view function is application/view.

视图函数的默认根路径是application/view

I had the same error. I was trying to access files like this

我有同样的错误。我试图访问这样的文件

 $this->load->view('pages/view/file.php');

Actually I have the class Pages and function. I built the function with one argument to call the any files from the director application/view/pages. I was put the wrong path. The above path pages/view/filescan be used when you are trying to access the controller. Not for the view. MVC gave a lot confusion. I had this problem. I just solve it. Thanks.

实际上我有类 Pages 和函数。我使用一个参数构建了该函数,以调用 Director application/view/pages 中的任何文件。我被放错了路径。当您尝试访问控制器时,可以使用上述路径pages/view/files。不为观。MVC 给了很多困惑。我有这个问题。我只是解决它。谢谢。

回答by Nassim

"Unable to load the requested file"

“无法加载请求的文件”

Can be also caused by access permissions under linux , make sure you set the correct read permissions for the directory "views/home"

也可能是linux下的访问权限导致,请确保为目录“views/home”设置了正确的读取权限

回答by james2doyle

I was getting this error in PyroCMS.

我在 PyroCMS 中收到此错误。

You can improve the error message in the Loader.php file that is in the code of the library.

您可以改进库代码中的 Loader.php 文件中的错误消息。

Open the Loader.php file and find any calls to show_error. I replaced mine with the following:

打开 Loader.php 文件并找到对show_error. 我用以下内容替换了我的:

show_error(sprintf("Unable to load the requested file: \"%s\" with instance title of \"%s\"", $_ci_file, $_ci_data['_ci_vars']['options']['instance_title']));

show_error(sprintf("Unable to load the requested file: \"%s\" with instance title of \"%s\"", $_ci_file, $_ci_data['_ci_vars']['options']['instance_title']));

I was then able to see which file was causing the issues for me.

然后我就能够看到是哪个文件导致了我的问题。

回答by Gufran Hasan

An Error Was Encountered Unable to load the requested file:

遇到错误无法加载请求的文件:

Sometimes we face this error because the requested file doesn't exist in that directory.

有时我们会遇到此错误,因为该目录中不存在请求的文件。

Suppose we have a folder homein viewsdirectory and trying to load home_view.phpfile as:

假设我们homeviews目录中有一个文件夹并尝试将home_view.php文件加载为:

$this->load->view('home/home_view', $data);// $data is array

If home_view.phpfile doesn't exist in views/homedirectory then it will raise an error.

如果home_view.php目录中不存在文件views/home,则会引发错误。

An Error Was Encountered Unable to load the requested file: home\home_view.php

遇到错误无法加载请求的文件:home\home_view.php

So how to fix this error go to views/homeand check the home_view.phpfile exist if not then create it.

那么如何修复这个错误去views/home检查home_view.php文件是否存在,如果不存在然后创建它。

回答by Areej Qasrawi

try $this->load->view('home/home_view',$data);

尝试 $this->load->view('home/home_view',$data);

instead of this:

而不是这个:

$this->load->view(‘home\home_view',$data);

$this->load->view(‘home\home_view',$data);