我想從第一次讀取excel文件,我有一些問題。我使用PhpExcel庫,我使用下面的代碼,現在Excel文件的文件夾中上傳的,但它不是顯示Excel文件中的任何數據,它給錯誤PhpExcel庫給出錯誤
"Error is catchedCould not open C:\xampp\tmp\phpF85B.tmp for reading! File does not exist."
及通告像
Notice: Undefined variable: obj in C:\xampp\htdocs\PhpExcel\index.php on line 24
Notice: Trying to get property of non-object in C:\xampp\htdocs\PhpExcel\index.php on line 24
最後
Fatal error: Call to a member function toArray() on a non-object in C:\xampp\htdocs\PhpExcel\index.php on line 24
<?php
if(isset($_POST['sub']) && !empty($_FILES['ex_file']['name'])){
$file=$_FILES['ex_file']['name'];
$type=explode(".",$file);
if(end($type)!= "xls" && end($type)!= "xlsx"){
echo "The File is not and excel file";
}
else{
include "PhpExcelLib/Classes/PhpExcel/IOFactory.php";
$dir="uploads/";
$name=$_FILES['ex_file']['name'];
$tmp_name=$_FILES['ex_file']['tmp_name'];
if(move_uploaded_file($tmp_name,$dir.$name)){
try{
$obj=PhpExcel_IOFactory::load($tmp_name);
}
catch(Exception $e){
echo "Error is catched". $e->getMessage();
}
$data=$obj->getActiveSheet->toArray(null,true,true,true);
print_r($data);
}
else{
echo "File is not uploaded";
}
}
}
?>
<html>
<body>
<form method="POST" enctype="multipart/form-data">
<label>Choose File To View Data</label>
<input type="file" name="ex_file" id="ex_file" />
<input type="submit" name="sub" value="Submit" />
</form>
</body>
</html>