Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. $zip = new ZipArchive();
  2. $filename = "gs://my_bucket/new_zip_file.zip";
  3. $toadd = 'gs://my_bucket/MakeaZip.txt';
  4.  
  5. if (file_exists($toadd)) {
  6. echo "The file $toadd exists<br>";
  7. } else {
  8. echo "The file $toadd does not exist<br>";
  9. }
  10.  
  11. if (is_writable('gs://my_bucket')) {
  12. echo 'Folder is writable<br>';
  13. } else {
  14. echo 'Folder not writable<br>';
  15. }
  16.  
  17. if ($zip->open($filename, ZipArchive::CREATE)!==TRUE) {
  18. echo 'Can not open '.$filename.'<br>';
  19. } else {
  20. echo 'Can open '.$filename.'<br>';
  21. }
  22.  
  23. $content = file_get_contents($toadd);
  24. $zip->addFromString(pathinfo ( $toadd, PATHINFO_BASENAME), $content);
  25.  
  26. echo "numfiles: " . $zip->numFiles . '<br>';
  27. echo "status:" . $zip->status . '<br>';
  28. echo 'GetStatusString: '.$zip->getStatusString() . '<br>';
  29. $ret = $zip->close();
  30. echo 'Closed with: ' . ($ret ? "true" : "false") . '<br>';
  31. echo 'GetStatusString: '.$zip->getStatusString() . '<br>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement