Can't load .xlsx file

Topics: User Forum
Sep 14, 2011 at 7:57 PM

I am using PHP version 5.3.8 with PHPExcel version 1.7.6 on Windows Server 2003.  When I try to load a .xlsx file I get this error:

Warning: ZipArchive::getFromName() [ziparchive.getfromname]: Invalid or unitialized Zip object in C:\Inetpub\wwwroot\Library\PHPExcel\Reader\Excel2007.php on line 300

I have traced the problem down to line 369 in PHPExcel\Reader\Excel2007.php, where it says $zip->open($pFilename);     This is returning 11 instead of the expected TRUE.  I think this means it can't open the zip archive.

At first I thought there was something wrong with the excel file, so I created a sample from scratch and used that, no luck.

 

The code I used:

$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objReader->load($_FILES['report1']['tmp_name']);

Sep 14, 2011 at 9:29 PM

After some more research it turns out it's not a PHPExcel problem but rather it's a ZipArchive problem, see: https://bugs.php.net/bug.php?id=54128

I temporary changed permissions on my TEMP directory (it's not a public server so I can get away with it for now) and everything works.

Jul 5, 2012 at 1:44 PM

Rather than messing with your Windows temp dir i would try editing your php.ini with a new temp upload dir and change the permissions on that instead:

upload_tmp_dir = C:\inetpub\temp\PHPUploadTemp