<?php
if (isset($_FILES) && count($_FILES) && isset($_FILES["subor"]) && $_FILES["subor"]["error"] == 0){
    $zip = new ZipArchive();
    $zip->open("subor.zip",ZIPARCHIVE::OVERWRITE);
    $zip->addFile($_FILES["subor"]["tmp_name"],$_FILES["subor"]["name"]);
    $zip->close();
    
    $file = "subor.zip";
    
    //orezanie koncovky suboru
    $meno = explode('.', $_FILES['subor']['name']);
    
    
    ob_start();
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($meno[0].".zip"));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    
    unlink($file);
    exit;
}
?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <form method="POST" action="" enctype="multipart/form-data">
            <input type="file" name="subor" >
            <input type="submit" value="ZIP">
        </form>
    </body>
    
</html>