I am working on project where I need to read an excel file sent in a form and then extract data from it. I am trying to use Phpspreadsheet library for the purpose but Phpspreadsheet library does not seems to recognize the file and throws an error: The file does not exist.
$product_serial = $this->input->post('product_serial');
$excelFilePath = base_url().'userfiles/product/excelfiles/'.$product_serial;
try {
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReaderForFile($excelFilePath);
$spreadSheet = $reader->load($excelFilePath);
$dataAsAssocArray = $spreadSheet->getActiveSheet()->toArray();
}
catch (\Exception $exception){
echo $exception->getMessage();
}
Error: File "http://localhost:8000/userfiles/product/excelfiles/452260670768Untitledspreadsheet.xlsx" does not exist
I have checked the file at above location the file does exist there!