Search code examples
phpoopzipphp-ziparchive

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


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?


Solution

  • 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