Error no such file or directory on server with Codeigniter

1


I have a project made with the framework Codeigniter which when uploading it to the server and trying to download an Excel file with the help of the PHPExcel library I'm getting the following error:

  

require_once (application / third_party / PHPExcel / PHPExcel.php): failed to open stream: No such file or directory

In local it works to me in the following way, in the folder libraries :

<?php 
if (!defined('BASEPATH')) exit('No direct script access allowed');  

require_once APPPATH."/third_party/PHPExcel/PHPExcel.php";
require_once APPPATH."/third_party/PHPExcel/PHPExcel/IOFactory.php";
class Excel extends PHPExcel {
    public function __construct() {
        parent::__construct();
    }
}

Try now in the following ways:

Manera 1:
    require_once "../third_party/PHPExcel/PHPExcel.php";
    require_once "../third_party/PHPExcel/PHPExcel/IOFactory.php";
Manera 2:
    require_once BASEPATH."third_party/PHPExcel/PHPExcel.php";
    require_once BASEPATH."third_party/PHPExcel/PHPExcel/IOFactory.php";

But nevertheless I still mark error, like I already gave permissions 777 to all the folders thinking that it is error per permissions, but it marks me the same error.
The structure of my folders is as follows:

I would appreciate any comments to solve my problem.

    
asked by J. Castro 27.07.2018 в 06:27
source

2 answers

0

It can be a problem of lowercase and uppercase, in the require it says PHPExcel and in the capture it says PhpExcel .

The reason that it works locally may be that you are using windows, which does not recognize differences between uppercase and lowercase. When testing it on the server (which is probably not windows) the upper and lower case are respected.

On the other hand APPPATH should already come with the last slash:

index.php (Codeigniter v2.x):

define('APPPATH', $application_folder.'/');

index.php (Codeigniter v3.x):

define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);

So

require_once APPPATH."third_party/PHPExcel/PHPExcel.php";

(without the / at the beginning) should work ferpecto.

    
answered by 01.08.2018 / 18:01
source
0

I think the best way is to use BASEPATH, so the solution I give you is to use this route:

require_once BASEPATH."application/third_party/PHPExcel/PHPExcel.php";
require_once BASEPATH."application/third_party/PHPExcel/PHPExcel/IOFactory.php";

Assuming that in BASEPATH you have put the path "/ public_html /", then you should go through the folders until you enter the two libraries.

If you do not want to use the full route, you can add another "../" such that:

require_once "../../third_party/PHPExcel/PHPExcel.php";
require_once "../../third_party/PHPExcel/PHPExcel/IOFactory.php";

Since you have the libraries folder with the first one, with the following marks the application folder and then you have to enter the folder "third_party / PHPExcel / PHPExcel / IOFactory.php".

    
answered by 01.08.2018 в 08:42