php - Fatal error: Uncaught PHPExcel_Reader_Exception: Could not open excel.csv for reading! File does not exist, or it is not readable -
i trying insert data excel database table, giving me fatal error. don't know how use phpexcel library properly. here error:
fatal error: uncaught phpexcel_reader_exception: not open export.xls reading! file not exist. in c:\xampp\htdocs\project\phpexcel\reader\excel5.php:433 stack trace: #0 c:\xampp\htdocs\project\phpexcel\iofactory.php(269): phpexcel_reader_excel5->canread('export.xls') #1 c:\xampp\htdocs\project\phpexcel\iofactory.php(191): phpexcel_iofactory::createreaderforfile('export.xls') #2 c:\xampp\htdocs\project\import_subject_allocation.php(9): phpexcel_iofactory::load('export.xls') #3 {main} thrown in c:\xampp\htdocs\project\phpexcel\reader\excel5.php on line 433
i have upload data excel file database , can't upload through csv file. rather not convert xls file csv file complicated , time consuming too
<?php require_once 'server_config.php'; $conn=myconnection(); include "phpexcel/iofactory.php"; require 'phpexcel.php'; if(isset($_request["import"])) { echo $filename = $_files["file"]["name"]; if ($_files["file"]["size"] > 0) { $objphpexcel=phpexcel_iofactory::load($filename); foreach ($objphpexcel->getworksheetiterator() $worksheet) { $highestrow= $worksheet->gethighestrow(); for($row=2;$row<=$highestrow;$row++) { $name=mysqli_real_escape_string($conn , $worksheet->getcellbycolumnandrow(0,$row)->getvalue()); $email=mysqli_real_escape_string($conn , $worksheet->getcellbycolumnandrow(1,$row)->getvalue()); $query = "insert test (`name`,`email`) values ('$name','$email')"; $n= iud($query); if($n){ echo "inserted"; }else echo "not"; } } } } ?> <form enctype="multipart/form-data" method="post" role="form"> <div class="form-group"> <label for="exampleinputfile">file upload</label> <input type="file" name="file" id="file" size="150"> <p class="help-block">only excel/csv file import.</p> </div> <button type="submit" class="btn btn-default" name="import" value="import">upload</button> </form>
at phpexcel_iofactory::load
need put file path parameter not file name concatenation like: $filepath."/".$filename
Comments
Post a Comment