简体   繁体   中英

PHP save zip to disk

I want to zip files uploaded by a user to a certain Location. While the upload part works, I have no Idea how to zip the file. I am able to create a zip, but do not now how to actually save it to a disk.

Simply pass the desired destination path to the zip when creating it:

$path = 'path/to/file.zip';
$zip = new ZipArchive();
$zip->open($path, ZipArchive::CREATE);
// add contents...
$zip->close();

This is gonna surely help you out....These are 2 well explained examples hope it helps ..

  1. http://www.9lessons.info/2012/06/creating-zip-file-with-php.html

  2. http://davidwalsh.name/create-zip-php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM