Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $zip = new ZipArchive();
- $filename = "gs://my_bucket/new_zip_file.zip";
- $toadd = 'gs://my_bucket/MakeaZip.txt';
- if (file_exists($toadd)) {
- echo "The file $toadd exists<br>";
- } else {
- echo "The file $toadd does not exist<br>";
- }
- if (is_writable('gs://my_bucket')) {
- echo 'Folder is writable<br>';
- } else {
- echo 'Folder not writable<br>';
- }
- if ($zip->open($filename, ZipArchive::CREATE)!==TRUE) {
- echo 'Can not open '.$filename.'<br>';
- } else {
- echo 'Can open '.$filename.'<br>';
- }
- $content = file_get_contents($toadd);
- $zip->addFromString(pathinfo ( $toadd, PATHINFO_BASENAME), $content);
- echo "numfiles: " . $zip->numFiles . '<br>';
- echo "status:" . $zip->status . '<br>';
- echo 'GetStatusString: '.$zip->getStatusString() . '<br>';
- $ret = $zip->close();
- echo 'Closed with: ' . ($ret ? "true" : "false") . '<br>';
- echo 'GetStatusString: '.$zip->getStatusString() . '<br>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement