Fatal error: Class 'PHPExcel_IOFactory' not found แก้ยังไงครับ
code หน้าแรก
Code (PHP)
<html>
<head>
<title></title>
</head>
<body>
<form name="form1" method="post" action="upload2.php" enctype="multipart/form-data">
<input type="file" name="filUpload">
<input name="btnSubmit" type="submit" value="Submit">
</form>
</body>
</html>
หน้าที่2 ที่เกิดการ error
Code (PHP)
<?php
$inputFileName = $_FILES["filUpload"]["name"];
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load($inputFileName);
if(move_uploaded_file($_FILES["filUpload"]["tmp_name"],"FileUpload/".$_FILES["filUpload"]["name"]))
{
echo "Copy/Upload Complete";
require_once 'Classes/PHPExcel.php';
require_once '../Build/PHPExcel.phar';
$objWorksheet = $objPHPExcel->setActiveSheetIndex(0);
$highestRow = $objWorksheet->getHighestRow();
$highestColumn = $objWorksheet->getHighestColumn();
$headingsArray = $objWorksheet->rangeToArray('A1:'.$highestColumn.'1',null, true, true, true);
$headingsArray = $headingsArray[1];
$r = -1;
$namedDataArray = array();
for ($row = 2; $row <= $highestRow; ++$row)
{
$dataRow = $objWorksheet->rangeToArray('A'.$row.':'.$highestColumn.$row,null, true, true, true);
if ((isset($dataRow[$row]['A'])) && ($dataRow[$row]['A'] > ''))
{
++$r;
foreach($headingsArray as $columnKey => $columnHeading)
{
$namedDataArray[$r][$columnHeading] = $dataRow[$row][$columnKey];
}
}
}
?>
<table width="500" border="1">
<tr>
<td>CustomerID</td>
<td>Name</td>
<td>Email</td>
<td>CountryCode</td>
<td>Budget</td>
<td>Used</td>
</tr>
<?php
foreach ($namedDataArray as $result)
{
?>
<tr>
<td><?=$result["CustomerID"];?></td>
<td><?=$result["Name"];?></td>
<td><?=$result["Email"];?></td>
<td><?=$result["CountryCode"];?></td>
<td><?=$result["Budget"];?></td>
<td><?=$result["Used"];?></td>
</tr>
<?php
}
}
?>
Date :
2017-01-30 15:49:57
By :
zzteamzz
เอาไว้บนสุดละ เป็นแบบนี้ครับ
Warning: require_once(../Build/PHPExcel.phar): failed to open stream: No such file or directory in C:\xampp\htdocs\PHPExcel\upload2.php on line 10
Fatal error: require_once(): Failed opening required '../Build/PHPExcel.phar' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\PHPExcel\upload2.php on line 10
Code (PHP)
<html>
<head>
<title></title>
</head>
<body>
<?php
require_once 'Classes/PHPExcel.php';
require_once 'Classes/PHPExcel.php';
require_once '../Build/PHPExcel.phar';
include 'Classes/PHPExcel/IOFactory.php';
$inputFileName = $_FILES["filUpload"]["name"];
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load($inputFileName);
if(move_uploaded_file($_FILES["filUpload"]["tmp_name"],"FileUpload/".$_FILES["filUpload"]["name"]))
{
echo "Copy/Upload Complete";
$objWorksheet = $objPHPExcel->setActiveSheetIndex(0);
$highestRow = $objWorksheet->getHighestRow();
$highestColumn = $objWorksheet->getHighestColumn();
$headingsArray = $objWorksheet->rangeToArray('A1:'.$highestColumn.'1',null, true, true, true);
$headingsArray = $headingsArray[1];
$r = -1;
$namedDataArray = array();
for ($row = 2; $row <= $highestRow; ++$row)
{
$dataRow = $objWorksheet->rangeToArray('A'.$row.':'.$highestColumn.$row,null, true, true, true);
if ((isset($dataRow[$row]['A'])) && ($dataRow[$row]['A'] > ''))
{
++$r;
foreach($headingsArray as $columnKey => $columnHeading)
{
$namedDataArray[$r][$columnHeading] = $dataRow[$row][$columnKey];
}
}
}
?>
<table width="500" border="1">
<tr>
<td>CustomerID</td>
<td>Name</td>
<td>Email</td>
<td>CountryCode</td>
<td>Budget</td>
<td>Used</td>
</tr>
<?php
foreach ($namedDataArray as $result)
{
?>
<tr>
<td><?=$result["CustomerID"];?></td>
<td><?=$result["Name"];?></td>
<td><?=$result["Email"];?></td>
<td><?=$result["CountryCode"];?></td>
<td><?=$result["Budget"];?></td>
<td><?=$result["Used"];?></td>
</tr>
<?php
}
}
?>
</table>
</body>
</html>
ประวัติการแก้ไข 2017-02-01 08:44:20
Date :
2017-02-01 08:43:30
By :
zzteamzz
มันหาไฟล์ไม่เจอนะครับ
Date :
2017-02-01 10:13:30
By :
mr.win
Load balance : Server 00