Zip Files
<?php
include_once
'CreateZipFile.inc.php'
;
$createZip
=
new
CreateZipFile;
$createZip
->addDirectory(
'/'
);
$filecontent1
=
file_get_contents
(
'fileone.txt'
);
$filecontent2
=
file_get_contents
(
'filetwo.txt'
);
$createZip
->addFile(
$filecontent1
,
'/fileone.txt'
);
$createZip
->addFile(
$filecontent2
,
'/filetwo.txt'
);
$zipFileName
=
'myzip.zip'
;
$handle
=
fopen
(
$zipFileName
,
'wb'
);
$out
= fwrite(
$handle
,
$createZip
->getZippedFile());
fclose(
$handle
);
$createZip
->forceDownload(
$zipFileName
);
@unlink(
$zipFileName
);
?>
Zip Folder
<?php
include_once
'CreateZipFile.inc.php'
;
$createZip
=
new
CreateZipFile;
$createZip
->zipDirectory(
'/testdir'
,
''
);
$zipFileName
=
'myzip.zip'
;
$handle
=
fopen
(
$zipFileName
,
'wb'
);
$out
= fwrite(
$handle
,
$createZip
->getZippedFile());
fclose(
$handle
);
$createZip
->forceDownload(
$zipFileName
);
@unlink(
$zipFileName
);
?>
No comments:
Post a Comment