RE: [PHP] zipfile problems - SOLVED

2005-04-08 Thread Allan, David (ThomasTech)
 -Original Message-

snip
 08while (false !== ($file = readdir($handle))){
 09$fn = explode(.,$file);
 10if ($fn[1]==pdf){
 11echo $inputpath.$file.br;
 12$handle = fopen($inputpath.$file,r);
 13$filedata = fread($handle, 
 filesize($inputpath.$file));
 14$zipfile - add_file($filedata, dir/.$file);
 15}
 16}

/snip


Do you need to also close the files you have opened?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] zipfile problems - SOLVED

2005-04-07 Thread George Pitcher
Hi all,

I found the cause of the problem.

01 $zipfile = new zipfile();
02 $zipfile - add_dir(dir/);
03 $inputpath = C:\\Program Files\\Apache
04 Group\\Apache2\\htdocs\\egretgui\\includes\\invoices\\;
05 $outputpath = C:\\;
06 $outfile = $outputpath.inv_.date(Y_m)..zip;
07 if ($handle = opendir($inputpath)) {
08  while (false !== ($file = readdir($handle))){
09  $fn = explode(.,$file);
10  if ($fn[1]==pdf){
11  echo $inputpath.$file.br;
12  $handle = fopen($inputpath.$file,r);
13  $filedata = fread($handle, filesize($inputpath.$file));
14  $zipfile - add_file($filedata, dir/.$file);
15  }
16  }
17 }
18 $fd = fopen ($outfile, wb);
19 $out = fwrite ($fd, $zipfile - file());
10 fclose ($fd);

It was the re-use of the variable '$handle' on line 12. I've now changed
that (and its uses) to '$handle2' and the problem has been solved.

Thanks to all for their suggestions.

George in rainy Oxford

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php