<?php
include_once("../class/class.MySQL.php");
$db	=new MySQL();
$vsdocs=$db->fetchQuery("SELECT * FROM visa_doc where e_id='".$_GET['employ_id']."'   order by id desc");
//error_reporting(-1);
foreach($vsdocs as $vsdocss){
	$vdocs[]= $vsdocss['visa_docs'];
}
						
				
$fileNames=$vdocs; 
$zip_file_name='../upload/visa/'.rand(15,1152).'visaFile.zip';
zipFilesDownload($fileNames,$zip_file_name);
 
 
function zipFilesDownload($file_names,$archive_file_name,$file_path=''){
	$zip = new ZipArchive();
	
	if ($zip->open($archive_file_name, ZipArchive::CREATE)!==TRUE) {
   	 exit("cannot open <$filename>\n");
	}

	foreach($file_names as $files){
 		$zip->addFile('../upload/visa/'.$files,$files);
	}
	$zip->close();
	
	$file_name = basename($archive_file_name);
	header("Content-Type: application/zip");
    header("Content-Disposition: attachment; filename=$file_name");
    header("Content-Length: " . filesize($archive_file_name));
    readfile($archive_file_name);
	unlink($archive_file_name);
	exit;
}



?>
