I am at the very beginning of an attempt to write some PHP code to run in a Linux box on an EC2 server that will read files from my S3 bucket, zip them, and then write the zip file back to the bucket.
I instantly ran into problems even when creating a simple zip archive from some images on the local drive of the EC2 instance. I use a script to test ideas from a PHP manual online, and also tried from a script from David Walsh - http://davidwalsh.name/create-zip-php , which looks like it would be great. Not a single result in the actual zip file, and both give me different status results -
the first snippet from the php manual (to which I add the $ thisdir variable) -
<?php $zip = new ZipArchive(); $filename = "test112.zip"; $thisdir = "/uploads/"; if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) { exit("cannot open <$filename>\n"); } $zip->addFromString("testfilephp.txt" . time(), "#1 This is a test string added as testfilephp.txt.\n"); $zip->addFromString("testfilephp2.txt" . time(), "#2 This is a test string added as testfilephp2.txt.\n"); $zip->addFile($thisdir . "/too.php","/testfromfile.php"); echo "numfiles: " . $zip->numFiles . "\n"; echo "status:" . $zip->status . "\n"; $zip->close(); ?>
output =
numfiles: 2 status: 11
I do not see any zip file in my uploads folder
The second bit of code I'm trying (I will not post code here) is transferring real files and it returns
The zip archive contains 2 files with status 0
What are the status messages. I checked if I have installed libraries by looking at the output of phpinfo (); and under the ZIP heading that I see -
Zip enabled
Extension version $ Id: php_zip.c, v 1.1.2.43 2008/01/18 00:51:38 pajoye Exp $
Print Version 1.8.11
Libzip version 0.8.0 compatible
I checked the file permissions of the PHP files with the code I execute, and they are set to 777, as well as the folder to which I am trying to add ziparchive. I know that this should not remain at 777.
any ideas why i can't see the zip file? What do status values ββmean? Is there a good tutorial for using PHP to zip files into an Amazon S3 bucket? or a good utility to provide this functionality?
amuses
php ziparchive
undefined
source share