Hi All,

 

I was able to solve the problem I was having  yesterday to zip an array of
files using a call to a php script. Here is an example you can use. Enjoy!

Michael

If (False)

  // METHOD: Php_ZipFiles

  // AUTHOR: MFERGUSON WITH BIG HELP FROM DAVID WALSH'S PHP SCRIPT

  // COMMENTS: TAKES POINTER TO ARRAY OF FILES TO ZIP, AND

  // PATH DESTINATION TO RESULTING ZIP FILE.

 

End if 

C_POINTER($1;$p_FilePaths)  // pointer to array of file paths to zip

c_text($2;$t_DestinationPath;$0)// destination path containing zip file name

 

$p_FilePaths:=$1

$t_DestinationPath:=$2

 

C_TEXT($t_ScriptPath;$t_FunctionName)

 

$t_ScriptPath:="Retrieve path to script here"

$t_FunctionName:="create_zip"

 

C_BOOLEAN($o_Err;$o_Result)

$o_Err:=PHP
Execute($t_ScriptPath;$t_FunctionName;$o_Result;$p_FilePaths;$t_DestinationP
ath)

If ($o_Err)

$0:=String($o_Result)

Else 

C_TEXT($t_ErrMessage)

ARRAY TEXT($at_ErrLabels;0)

ARRAY TEXT($at_ErrValues;0)

ARRAY TEXT($at_HeaderFields;0)

ARRAY TEXT($at_HeaderValues;0)

PHP GET FULL
RESPONSE($t_ErrMessage;$at_ErrLabels;$at_ErrValues;$at_HeaderFields;$at_Head
erValues)

 

// display or log error here from error arrays

 

$0:="The Php command failed."

End if 

  // END OF ROUTINE

  //------------------------------------

 

  //SCRIPT, REMOVE ALL //

 

  //<?php

  ///*creates a compressed zip file*/

  //function create_zip($files=array(),$destination='',$overwrite=False){

  //  //if the zip file already exists and overwrite is false, return false

  //If (file_exists($destination) &  & !$overwrite){return false;}

  //  //vars

  //$valid_files=array();

  //  //if files were passed in...

  //If (is_array($files)){

  //  //cycle through each file

  //foreach($files as$file){

  //  //make sure the file exists

  //If (file_exists($file)){

  //$valid_files[]=$file;

  //}

  //}

  //}

  //  //if we have good files...

  //If (count($valid_files)){

  //  //create the archive

  //$zip=new ZipArchive();

  //If ($zip->open($destination,$overwrite? Z)!==True){

  //return false;

  //}

  //  //add the files

  //foreach($valid_files as$file){

  //$zip->addFile($file,$file);

  //}

  //  //debug

  //  //echo 'The zip archive contains ',$zip->numFiles,' files with a
status of ',$zip->status;

 

  //  //close the zip -- done!

  //$zip->close();

 

  //  //check to make sure the file exists

  //return file_exists($destination);

  //}

  //Else 

  //{

  //return false;

  //}

  //}

  //?>

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to