Special unzip situation - is it possible?

Our situation:

A person uploads a .zip file and it may contain more .zip files (inside of which are .txt files) and it may also have folders containing .txt files (not zipped).

E.g. Archive.zip might contain:

foo.zip (contains 4 text files)
bar.zip (contains 8 text files)
widgets/file2.txt
widgets/file3.txt

We need to extract all .txt files into 1 directory. We do not want to maintain the directory structure of the uploaded .zip

Is this possible and where should I be looking? My Google searches have resulted in tutorials or code to solve this unique situation.

Thanks in advance.

I’d extract “level by level” - the whole zip file into one dir and then iterate over the tree, renaming all “wanted files” to unique names and moving them to a destination dir.
While iterating you’ll get the names of further zips so do the same with them, but probably to another temp dir to prevent overwriting anything.
This way there should be no problem with files with similar names in e.g. subdirectories or “sub-zipfiles”.

The code itself doesn’t differ from extracting a single zip, you’ll only have to use e.g. RecursiveDirectoryIterator on the extracted file trees.

Thanks for replying and suggestion. I will look into this more carefully. I was told that using the command line might be more efficient/powerful but that’s out of my skillset.

Command line scripting with PHP is not much of a difference.
I’d go with a cronjob in most cases, so customers can upload a zip file and it’ll be processed later by the cron.

Thanks - we’re doing real-time data analysis and reporting as soon as files are uploaded