track results of $zip->expandTo in order to log files?

42 Views Asked by At

I am using the PHP zipArchive class to uncompress files and store them on a server, but I have a couple of problems

extractTo method only returns true or fales, I need a list of the file names and types to that I can

  • Check they are valid file types for the function
  • Connect the files with database objects for retrieval

Any ideas?

2

There are 2 best solutions below

0
On BEST ANSWER

Answering my own question for completeness, the DirectoryIterator is the best way. The process being:

  • Create Temp folder
  • Extract
  • Check with DirectoryIterator class
  • Move to Permanent location
  • Delete Temp folder
3
On

you can extend the class, adding a logging function which then passes through the params to the extractTo method...

see: http://php.net/manual/en/keyword.extends.php