xls/xlsx to csv include_once warnings

Topics: User Forum
Jul 3, 2012 at 3:44 PM
Edited Jul 3, 2012 at 3:46 PM

Greetings! 

- PHP5

- Zend Framework 1.11

- WAMP (php_zip is enabled)

- PHPExcel_1.7.7

 

I’m attempting to convert xls and xlsx files uploaded by a user to csv files, and then save them on my server.

 

The actual conversion process works the like a charm, the file appears in the proper directory in the proper format (csv). However, running it produces a mountain of inclusion warnings (I've only shown the first of each set since I assume the problems all stem from the same mistake). I’ve used “die()” to narrow down where these errors are coming from.

 

Code:

:: upload.php ::

<?php

$convertedFilePath = $uploadDirectory . $fileData['filename']['name'] . '.csv';

if (isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {

 $fileNameArray = explode(".", $_FILES['filename']['name']);

        $fileExtension = end($fileNameArray);

if (strcmp(strtolower($fileExtension), "csv") != 0) {

 

Warning: include_once(PHPExcel\Shared\ZipStreamWrapper.php) [function.include-once]: failed to open stream: No such file or directory in ...\trunk\library\Zend\Loader.php on line 146

 

require ‘…\trunk\application\controllers\helpers\xlsConverter.php';

        converter($filePath, $convertedFilePath);

                $filePath = $convertedFilePath;

}

}

?>

:: xlsConverter.php ::

<?php

require_once ‘…\trunk\public\libraries\PHPExcel_1.7.7\Classes\PHPExcel\IOFactory.php';

function converter($sourceFilePath,$destinationFilePath) {            

$excel = PHPExcel_IOFactory::load($sourceFilePath);

 

Warning: include_once(PHPExcel\Reader\Excel5.php) [function.include-once]: failed to open stream: No such file or directory in ...\trunk\library\Zend\Loader.php on line 146

               

$writer = PHPExcel_IOFactory::createWriter($excel, 'CSV');

        $writer->setDelimiter(",");

        $writer->setEnclosure("");

        $writer->save($destinationFilePath);

 

Warning: include_once(PHPExcel\Writer\CSV.php) [function.include-once]: failed to open stream: No such file or directory in ...\trunk\library\Zend\Loader.php on line 146}

?>

Any help and explanation of the problem would be appreciated!

Best,

lost

Aug 16, 2012 at 4:11 PM

I am having similar problems :(

Coordinator
Aug 16, 2012 at 5:47 PM

If the problem is integration into Zend Framework:

 

Place the PHPExcel library into the /library folder, like this:

/application 
... 
/library 
    /PHPExcel 
    /PHPExcel.php 

In your application.ini config file, add the following:

autoloaderNamespaces[] = "PHPExcel_" 
autoloaderNamespaces[] = "PHPExcel"