Hello!! first off all, great package!
I'm having an specific issue when deploying in IIS and is driving me crazy, I guess it might be a problem from the package thats why I'm posting the issue. This app (w/Laravel) simply gets an excel from the user and save it on the DB.
First I had this issue: when uploading the file, the route was wrong, appending 2 routes like this: "c:\www\myapp\c:\windows\temp\file.tmp" which was weird, but I commented the "if" in LaravelExcelReader.php line 734:
// if (!$noBasePath && !realpath($file)) {
// $file = base_path($file);
// }
Now, it finds the file (yayy!!!) butit looks empty. And the same code stills works on local (XAMPP).
This is the line that gets the excel file in my controller:
Excel::selectSheets('content')->load($request->file('sheet'), function($reader) {
the result in my local xampp where it works is:
Maatwebsite\Excel\Collections\CellCollection Object
(
[title:protected] =>
[items:protected] => Array
(
[content_name] => Aries 25012016
[content_type] => 1
[content_body] => Loremipsumdolorsitametconsecteturblablalblabla....
)
)
but, in IIS I'm having this:
Maatwebsite\Excel\Collections\CellCollection Object
(
[title:protected] =>
[items:protected] => Array
(
)
)
So, I don't know where to break to fix this. I already check file permissions, my app (laravel) has access to all directories with no restrictions. I guess it might be the way the package handles the file..?. Not sure.
Thanks for your help!
Diego
Hey
I honestly don't know an aweful lot about IIS and can't reproduce it.
Did you google PHPEXCEL IIS? Maybe something like this http://stackoverflow.com/questions/5368362/phpexcel-import-fails-during-load-on-iis could be the issue?
Thanks Patric. Yes I did, checked permissions and all. It doesn't seem to be the problem. I put the code the way it was before my changes, and this is the original error laravel gives me:
PHPExcel_Reader_Exception in Excel2007.php line 82:
Could not open C:\inetpub\www_horoscopo\laravel\C:\Windows\Temp\php7D19.tmp for reading! File does not exist.
in Excel2007.php line 82
at PHPExcel_Reader_Excel2007->canRead('C:\inetpub\www_horoscopo\laravel\C:\Windows\Temp\php7D19.tmp') in FormatIdentifier.php line 249
at FormatIdentifier->canRead('Excel2007', 'C:\inetpub\www_horoscopo\laravel\C:\Windows\Temp\php7D19.tmp') in FormatIdentifier.php line 229
at FormatIdentifier->lastResort('C:\inetpub\www_horoscopo\laravel\C:\Windows\Temp\php7D19.tmp', null, 'tmp') in FormatIdentifier.php line 55
at FormatIdentifier->getFormatByFile('C:\inetpub\www_horoscopo\laravel\C:\Windows\Temp\php7D19.tmp') in LaravelExcelReader.php line 1128
at LaravelExcelReader->_setFormat() in LaravelExcelReader.php line 660
at LaravelExcelReader->_init(object(UploadedFile), null, false) in LaravelExcelReader.php line 255
at LaravelExcelReader->load(object(UploadedFile), null, false) in Excel.php line 118
at Excel->load(object(UploadedFile), object(Closure)) in ExcelController.php line 107
at ExcelController->store(object(Request))
at call_user_func_array(array(object(ExcelController), 'store'), array(object(Request))) in Controller.php line 256
at Controller->callAction('store', array(object(Request))) in ControllerDispatcher.php line 164
at ControllerDispatcher->call(object(ExcelController), object(Route), 'store') in ControllerDispatcher.php line 112
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Authenticate.php line 45
at Authenticate->handle(object(Request), object(Closure))
at call_user_func_array(array(object(Authenticate), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 114
at ControllerDispatcher->callWithinStack(object(ExcelController), object(Route), object(Request), 'store') in ControllerDispatcher.php line 69
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\ExcelController', 'store') in Route.php line 201
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134
at Route->run(object(Request)) in Router.php line 704
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 706
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 671
at Router->dispatchToRoute(object(Request)) in Router.php line 631
at Router->dispatch(object(Request)) in Kernel.php line 236
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 54
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 122
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 58
Of course, this works perfectly with xampp on windows. As you can see, the path is wrong (C:\inetpub\www_horoscopo\laravel\C:\Windows\Temp\php7D19.tmp). I don't know what else to check.
I'm having the same problem, with the same errors. Works on xampp, doesn't work on IIS.
This code get the excel file in my controller on xampp:
$srImport = Excel::load($request->file('srImport'), function($reader) {
})->get();
But gets me this error on IIS:
PHPExcel_Reader_Exception in Excel2007.php line 82:
Could not open C:\inetpub\wwwroot\prisonjustice/C:\Windows\Temp\php742.tmp for reading!
File does not exist.
I checked the 'C:\Windows\Temp\' directory on the IIS server. There is a php742.tmp file.
And this code works in xampp but gets me an empty collection in IIS:
$srImport = Excel::load($request->file('srImport'), function($reader) {
}, false, true)->get();
I found the solution! I added this to the top of the controller
use PHPExcel_Settings;
And this in the controller:
PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);
Here is the explanation from the PHPExcel documentation:
PHP complains about ZipArchive not being found
Make sure you meet all Requirements, especially php_zip extension should be enabled.
The ZipArchive class is only required when reading or writing formats that use Zip compression (Excel2007 and OOCalc). From version 1.7.6 the PCLZip library has been bundled with PHPExcel as an alternative to the ZipArchive class.
This can be enabled by calling:
PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);
before calling the save method of the Excel2007 Writer.
You can revert to using ZipArchive by calling:
PHPExcel_Settings::setZipClass(PHPExcel_Settings::ZIPARCHIVE);
At present, this only allows you to write Excel2007 files without the need for ZipArchive (not to read Excel2007 or OOCal
Glad it solved your problem, although those notes are slightly out of date.... PHPExcel_Settings::PCLZIP is now supported for Readers as well as Writers
Sadly, it didn't solve the problem to me, I'm still having the wrong address.
Hello, may be you solved time ago, but I find out another way, I hope it can be helpfull for someone:
The load() method has 4 parameters, and the fourth one fix the issue for me:
Sintax:
Excel::load(file_path, callback, encoding, noBasePath)
The "noBasePath" by default is false, and because of it occurs the
PHPExcel_Reader_Exception in Excel2007.php line 82:
Could not open C:\inetpub\www_horoscopo\laravel\C:\Windows\Temp\php7D19.tmp for reading! File does not exist.
When the fourth parameter is set to true it looks like this:
C:\Windows\Temp\php7D19.tmp
Example:
$excel = \Excel::load($request->file('ExcelFile')->getPathName(),function($reader) {
_your code_
} ,null,_true_)->get();
I use ubuntu 16.04 and php 5.6.
so apt-get install php5.6-zip solved my problem
@jofelgarze Confirmed your solution worked for me. Thank you. I was having the same problem from development to production on Digital Ocean Ubuntu LAMP.
you麓re welcome!! it麓s nice to know it help you!!
This is mine... Please Help....
Error loading file "Animal.xlsx": Could not open temp/Animal.xlsx for reading! File does not exist.
set_include_path(get_include_path() . PATH_SEPARATOR . 'Classes/');
/** PHPExcel_IOFactory */
include 'PHPExcel/IOFactory.php';
move_uploaded_file($_FILES["file"]["tmp_name"],
"temp/" . $_FILES["file"]["name"]) ;
$inputFileName = "temp/".$_FILES["file"]["name"]; // File to read
//echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory to identify the format
';
try {
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
} catch(Exception $e) {
die('Error loading file "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e->getMessage());
}
STILL can't solve the ERROR:
Error loading file "Animal.xlsx": Could not open temp/Animal.xlsx for reading! File does not exist.
Most helpful comment
I found the solution! I added this to the top of the controller
use PHPExcel_Settings;And this in the controller:
PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);Here is the explanation from the PHPExcel documentation: