File: /home/imensosw/www/imenso.co/dev/data-panel/download_excel.php
<?php
error_reporting(0);
require_once 'config.php';
include('PHPExcel/Classes/PHPExcel/IOFactory.php');
$doc_no = $_POST['list'][0];
if(isset($doc_no))
{
$doc_no = explode(',', $doc_no);
$error = "";
$filePath = "docs/";
if(extension_loaded('zip'))
{
if(isset($doc_no) && count($doc_no)>0)
{
$zip = new ZipArchive();
$zip_name = date("Y-m-d").".zip";
if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE)
{
//$error.="Sorry zip creation failed.";
}
foreach($doc_no as $file)
{
$zip->addFile($filePath."$file/$file.xls","$file.xls");
// $zip->addFile($filePath."$file/$file.xls"); // Adding files into zip
}
$zip->close();
if(file_exists($zip_name))
{
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="'.$zip_name.'"');
readfile($zip_name);
// remove zip file is exists in temp path
unlink($zip_name);
}
else
{
//$error .= "File not exists ";
}
}
else
{
//$error .= "* Please select file to zip ";
}
}
/*$_SESSION['file_error'] = $error;
header("location:".$url."admin/assignment_completed.php");*/
}
?>