<?php
session_start();
include "../class/class.MySQL.php";
$db=new MySQL();


$rect_id    = $_GET['rect_id'];
$getresumes = $db->fetchQuery("SELECT rect_resumeup FROM recruitment_resumes WHERE rect_id=".$rect_id);

foreach($getresumes  as $resumes){
	$zip_files[] = $resumes['rect_resumeup'];
}

$fileNames=$zip_files; 
$zip_file_name='../upload/resume/'.rand(15,1152).'resume.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/resume/'.$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;
}




?> 