I have the following code:
require_once "../vendor/autoload.php";
require_once '../vendor/phpoffice/phpexcel/Classes/PHPExcel/IOFactory.php';
$target_dir = "coverImages/";
$target_file = $target_dir . basename($_FILES["excelfile"]["name"]);
move_uploaded_file($_FILES["excelfile"]["tmp_name"], $target_file);
if ($_FILES["excelfile"]["error"] > 0)
{
echo "Error: " . $_FILES["excelfile"]["error"] . "<br>";
}
else
{
if (file_exists($target_file)) {
echo "file exists!";
}else{
echo "oh it does not";
}
$objPHPExcel = PHPExcel_IOFactory::load($target_file);
}
I am getting the file from an input file. I am moving the file to a location on my server. But I cannot load the file once I have it moved. I am verifying the file exists, but phpoffice won't grab my file when I call load on a Factory and gives me a 500 error. Any advice can help me, thanks in advance.
EDIT: Error returned:
Fatal error: Uncaught Error: Class 'ZipArchive' not found in /app/vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2007.php:94 Stack trace: #0 /app/vendor/phpoffice/phpexcel/Classes/PHPExcel/IOFactory.php(268): PHPExcel_Reader_Excel2007->canRead('coverImages/Boo...') #1 /app/vendor/phpoffice/phpexcel/Classes/PHPExcel/IOFactory.php(191): PHPExcel_IOFactory::createReaderForFile('coverImages/Boo...') #2 /app/public/upload_file.php(26): PHPExcel_IOFactory::load('coverImages/Boo...') #3 {main} thrown in /app/vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2007.php on line 94
Not sure why there is an error, in my dockerfile I am calling:
RUN apt-get update && \
apt-get install -y \
freetds-dev \
libsybdb5 \
wget \
zip
So zip should be installed.