CodeIgniter: failed to open stream: No such file or directory

22.9k views Asked by At

i am having a

A PHP Error was encountered

Severity: Warning

Message: require_once(/../scraper_utilities.php): failed to open stream: No such file or directory

Filename: utility_classes/special_price_process.php

Line Number: 3

I only have just included a file scraper_utilities.php by this:

require_once('/../scraper_utilities.php');

Here is the file system of the codeigniter i am currently using:

enter image description here

EDIT: I Also tried

 require_once('../scraper_utilities.php');

And

require_once(__DIR__.'/scraper_ci/application/libraries/scraper_utilities.php');

but didn't also worked.

3

There are 3 answers

0
James Taylor On

Remove that first / so:

require_once('../scraper_utilities.php');

../ will take you up one directory, the initial / takes you all the way up to the root directory

1
Christian Burgos On

i solved it by using APPPATH

require_once(APPPATH.'libraries/scraper_utilities.php');
0
Bilal Ahmad On

Use APPPATH to locate your file in your project. In codeigniter you are not allowed to go back in directory instead you will need to use APPPATH which will give you the application root directory.

In your case it's gonna be like.

require_once(APPPATH.'utility_classes/special_price_process.php');