我制作了一个html表单,将excel表导入mysql。从表单加载后,文件以.tmp扩展名存储在内存中。如何使用phpexcel解析此.tmp文件?或者有更好的方法从html表单加载它并直接解析? 我的代码;
<form action='load.php' method="POST" enctype="multipart/form-data">
<p><input type="file" name='excelfile'/></p>
<p><button type="button">upload</button></p>
</form>
//load.php
<?php
if (!empty($_FILES["excelfile"])) {
if ($excel["error"] !== UPLOAD_ERR_OK) {
echo "<p>An error occurred.</p>";
exit;
}
else {
echo "File uploaded";
require '../class/PHPExcel.php';
require_once '../class/PHPExcel/IOFactory.php';
$path = ????; //....how to parse this file, now stored as filename.tmp
$objPHPExcel = PHPExcel_IOFactory::load($path);
//........
}
}
?>
答案 0 :(得分:1)
您可以获得以下tmp路径:
$path=$_FILES['excelfile']['tmp_name'];