forked from svn2github/dotnetzip
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateZip-DotNetZip.php
More file actions
43 lines (33 loc) · 1017 Bytes
/
Copy pathCreateZip-DotNetZip.php
File metadata and controls
43 lines (33 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
try
{
echo '<html>';
echo ' <head>';
echo ' <title>Calling .NET from PHP through COM</title>';
echo ' <link rel="stylesheet" href="basic.css"/>';
echo ' </head>';
echo '<body>';
echo '<h2>Hello!</h2>' . "<br/>\n";
echo '<h4>Trying static method</h4>' . "<br/>\n";
$fname = "archive-" . date('Y-m-d-His') . ".zip";
echo 'Dynamically generated archive name: ' . "\n" . '<h4>' . $fname . "</h4>\n";
$zipOutput = "c:\\temp\\php-" . $fname;
$zipfact = new COM("Ionic.Zip.ZipFile");
$zip = $zipfact->Read($zipOutput);
$zip->Encryption = 3;
$zip->Password = "AES-Encryption-Is-Secure";
$dirToZip= "c:\\temp\\psh";
$zip->AddDirectory($dirToZip);
$zip->Save();
echo '<br/>The file was saved to ' . $zip->Name . '<br/>' . "\n";
$zip->Dispose();
echo '</body>';
echo '</html>';
}
catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
echo '<pre>';
echo $e->getTraceAsString(), "\n";
echo '</pre>';
}
?>