Skip to content

Instantly share code, notes, and snippets.

@kraken-chris
Created March 30, 2023 19:28
Show Gist options
  • Save kraken-chris/16b28f2b015aeee4f3d9a204df21a2f6 to your computer and use it in GitHub Desktop.
Save kraken-chris/16b28f2b015aeee4f3d9a204df21a2f6 to your computer and use it in GitHub Desktop.
Create zip archive from files uploaded in a form
$zip = new Zip();
$zip->setArchive($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'media/ziptest.zip');
$location = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'media/zip_test/';
move_uploaded_file($_FILES['file0']['tmp_name'], $location . 'tmp_file0.pdf');
move_uploaded_file($_FILES['file1']['tmp_name'], $location . 'tmp_file1.pdf');
$fileArchive = $zip->compress($_FILES['file0']['tmp_name']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment