aboutsummaryrefslogtreecommitdiff
path: root/examples/03-add_stream.php
diff options
context:
space:
mode:
Diffstat (limited to 'examples/03-add_stream.php')
-rw-r--r--examples/03-add_stream.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/03-add_stream.php b/examples/03-add_stream.php
new file mode 100644
index 0000000..68895b3
--- /dev/null
+++ b/examples/03-add_stream.php
@@ -0,0 +1,24 @@
+<?php
+
+require_once __DIR__ . '/../src/ZipStream.php';
+
+# import zipstream class
+use Pablotron\ZipStream\ZipStream;
+
+# set source path
+$src_path = __DIR__ . '/03-add_stream.php';
+
+# create the output archive named "example.zip"
+$zip = new ZipStream('example.zip');
+
+# open stream
+$src = fopen($src_path, 'rb');
+
+# read from source stream and add it to the archive as "example.php"
+$zip->add_stream('example.php', $src);
+
+# close input stream
+fclose($src);
+
+# finalize the output stream
+$zip->close();