I am trying to import excel file using library PHPexcel, but when choosing file and submitting it, it fires Error : Unable to load the file : "1.xlsx": Could not open 1.xlsx for reading! File does not exist... why? can you help plz!
here is code:
<form name="import" method="post" enctype="multipart/form-data">
<input type="file" name="file" /><br />
<input type="submit" name="submit" value="Submit" />
</form>
and:
<?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());
}
}
?>
if i want to write the file path instead of $filename
and the file in the project itself, what can i write?