CodeIgniter: Failed to load the requested file:

Hi, I'm just new to codeigniter. My site works locally, but when I downloaded it, I got this error:

An error was detected. The requested file could not be loaded: 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!

+10
source share
6 answers

to try

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

(and note the "'", not the "" you used)

+18
source

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

+9
source

Error. When you try to access a file that is not in the directory. Check the path in the view carefully

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

The default root path function is application / view .

I had the same error. I tried to access such files

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

Actually, I have a Pages class and a function. I built a function with one argument to call any files from the application / view / pages directory. I had the wrong way. The above page path / view / files can be used when you are trying to access the controller. Not for presentation. MVC has given a lot of confusion. I had this problem. I just solve it. Thank you

+1
source

I was getting this error in PyroCMS.

You can improve the error message in the Loader.php file, which is located in the library code.

Open the Loader.php file and find any show_error calls. I replaced my following:

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

Then I was able to see which file was causing problems for me.

0
source

An error has been detected. Unable to load requested file:

Sometimes we encounter this error because the requested file does not exist in this directory.

Suppose we have a home folder in the views directory and we are trying to load the home_view.php file as:

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

If the home_view.php file home_view.php not exist in the views/home directory this will cause an error.

An error has been detected. Unable to load requested file: home \ home_view.php

So, how to fix this error, go to views/home and check if the file home_view.php if not, create it.

0
source

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

instead of this:

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

0
source

Source: https://habr.com/ru/post/916069/


All Articles