CodeIgniter : Unable to load the requested file:
Asked Answered
F

7

10

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

An Error Was Encountered Unable to load the requested file: 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!

Friedland answered 18/5, 2012 at 7:49 Comment(1)
in my case folder's first letter was capital and in code I wrote small .. it worked on local but was not working in productionFeeder
C
21

try

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

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

Corrosion answered 18/5, 2012 at 8:3 Comment(2)
oh - and one other idea - check the filename "home_view" is in lowercase - it might work on a windows machine, where it is case insensentiveCorrosion
still, I have the error. ` <?php $this->load->view('$main_content');?> ` in template.php and $data['main_content'] = 'login_form'; $this->load->view('includes/template',$data); in login.php....?Elaterin
H
10

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

Hadrian answered 26/8, 2012 at 11:57 Comment(1)
What if the file names are correct and still have the error.Elaterin
C
2

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

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

default root path of view function is 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/files can 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.

Companion answered 10/12, 2014 at 16:22 Comment(0)
G
1

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

instead of this:

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

Guadalajara answered 21/6, 2019 at 10:24 Comment(0)
D
1

"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"

Diastasis answered 17/9, 2019 at 11:15 Comment(1)
confirmed this is one possible cause :)Unshapen
K
0

I was getting this error in PyroCMS.

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

Open the Loader.php file and find any calls to show_error. I replaced mine with the 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']));

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

Knapsack answered 17/9, 2017 at 1:1 Comment(0)
S
0

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 home in views directory and trying to load home_view.php file as:

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

If home_view.php file doesn't exist in views/home directory then it will raise an error.

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

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

Spastic answered 1/4, 2019 at 9:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.