我正在尝试使用库PHPexcel导入excel文件,但在选择文件并提交时,它会触发错误:无法加载文件:" 1.xlsx":无法打开1.xlsx for读!文件不存在......为什么?你可以帮助PLZ!
这是代码:
<form name="import" method="post" enctype="multipart/form-data">
<input type="file" name="file" /><br />
<input type="submit" name="submit" value="Submit" />
</form>
和:
<?php
error_reporting(0);
include 'Classes/PHPExcel/IOFactory.php';
if(isset($_POST["submit"]))
{
$name = pathinfo($_FILES['file']['name'], PATHINFO_FILENAME);
$ex = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
$filename = $name. '.' .$ex;
try {
$objPHPExcel = PHPExcel_IOFactory::load($filename);
} catch(Exception $e) {
die('Error : Unable to load the file : "'.pathinfo($_FILES['file']['name'],PATHINFO_BASENAME).'": '.$e->getMessage());
}
}
?>
如果我想写文件路径而不是$filename
和项目本身的文件,我能写什么?