Active
Project:
Computed Field
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
24 Dec 2011 at 16:52 UTC
Updated:
24 Dec 2011 at 16:52 UTC
when I click on a button, I want to create a ziparchive of all of the images in this node type.
So, I am starting out small and using the examples on the PHP manual. but not having luck writing to the local HD... I commented a lot of my mistakes out. the code is at the bottom, but I left the commented stuff in just to show where I was going.
There is no button here, it is just returning the the responce from creating the zip file... which usually comes back good... but there are no zip files being created.
every time I create a zip, it should delete the old zip and create a new one. no zip updates or adds.
any sugestions
//$entity_field[0]['value'] = "";
//$entity_field[0]['value'] = "";
//$entity_type = 'node';
// If the key inside items is uri:
//$items = field_get_items($entity_type, $entity, 'field_field_image01');
//$uri = $items[0]['uri'];
//$path = file_create_url($uri);
//$entity_field[0]['value'] = $path;
// first copy the new image to a special directory
//$specialDir = 'specialvy01';
//$zip = new ZipArchive();
//$filename = "test112.zip";
//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");
//$zip->addFile('testzipfromphp' . "/too.php","/testfromfile.php");
//echo "numfiles: " . $zip->numFiles . "\n";
//echo "status:" . $zip->status . "\n";
//$zipresponce=$zip->numFiles .'---'.$zip->status;
//$zip->close();
//$entity_field[0]['value'] = $entity->nid;
//
$zipresponce='--starting--';
//$zip = new ZipArchive;
//$res = $zip->open('test.zip', ZipArchive::CREATE);
//if ($res === TRUE) {
// $zip->addFromString('test.txt', 'file content goes here');
// $zip->addFile('data.txt', 'entryname.txt');
// $zip->close();
// echo 'ok';
// $zipresponce='--zip all good ===';
//} else {
// echo 'failed, code:' . $res;
// $zipresponce='--zip NO good';
//}
$zip = new ZipArchive();
$filename = "test112.zip";
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
$zipresponce = ("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";
$zipresponce = "numfiles: " . $zip->numFiles . " status:" . $zip->status . "\n";
$zip->close();
$entity_field[0]['value'] =$zipresponce;