gibberish
gibberish

Reputation: 111

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.

Upvotes: 11

Views: 14580

Answers (2)

Havelock
Havelock

Reputation: 6968

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();

Upvotes: 14

Php Geek
Php Geek

Reputation: 1107

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

Upvotes: 2

Related Questions