php - PhpExcel Reader: Couldn't read certain files -


error shows ->warning: ziparchive::getfromname(): invalid or unitialized zip object

when uploading files, , reading excel files, shows error message.

this code:

$pasfile    = $_files['inputfilelocation']['name']; $target_path    = basename($pasfile); if(move_uploaded_file($_files["inputfilelocation"]["tmp_name"], $target_path)){         require_once '../template/phpexcel/classes/phpexcel.php';         $objreader = phpexcel_iofactory::createreader('excel2007');         $worksheet_names = $objreader->listworksheetnames($pasfile);         $countworksheet = count($worksheet_names);         $optionsheetname = "<option></option>";         for($x = 0;$x < $countworksheet;$x++){             $optionsheetname = $optionsheetname."<option value='".$worksheet_names[$x]."'>".$worksheet_names[$x]."</option>";         }     } 

thank in advance! :)

my mistake! file uploading had different types of excel format.

this code works identifying format passing create reader. many mr. baker! added codes:

    $inputfiletype = phpexcel_iofactory::identify($pasfile);     $objreader = phpexcel_iofactory::createreader($inputfiletype); 

resulting one:

$pasfile    = $_files['inputfilelocation']['name']; $target_path    = basename($pasfile); if(move_uploaded_file($_files["inputfilelocation"]["tmp_name"], $target_path)){         require_once '../template/phpexcel/classes/phpexcel.php';         $inputfiletype = phpexcel_iofactory::identify($pasfile);         $objreader = phpexcel_iofactory::createreader($inputfiletype);         $worksheet_names = $objreader->listworksheetnames($pasfile);         $countworksheet = count($worksheet_names);         $optionsheetname = "<option></option>";         for($x = 0;$x < $countworksheet;$x++){             $optionsheetname = $optionsheetname."<option value='".$worksheet_names[$x]."'>".$worksheet_names[$x]."</option>";         }     } 

identify() first before createreader()...


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -