Created
October 27, 2021 11:15
-
-
Save luizmarcus/635c905af74bc974ddf5f69820c71779 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//identificador unico para o arquivo | |
define('TOKEN',md5(uniqid(rand(), true))); | |
function zipFiles(){ | |
$zip = new ZipArchive(); | |
$DelFilePath=$_SERVER['DOCUMENT_ROOT']."/seubot/files/".TOKEN.".zip"; | |
if(file_exists($DelFilePath)) { | |
unlink($DelFilePath); | |
} | |
if ($zip->open($DelFilePath, ZIPARCHIVE::CREATE) != TRUE) { | |
die("Could not open archive"); | |
} | |
$path=$_SERVER['DOCUMENT_ROOT']."/seubot/files"; | |
$files = scandir($path); | |
$files = array_diff(scandir($path), array('.', '..')); | |
foreach($files as $file){ | |
$zip->addFile($_SERVER['DOCUMENT_ROOT']."/seubot/files/".$file,$file); | |
} | |
// close and save archive | |
$zip->close(); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment