I have a tar.gz-file with the following structure:

folder1/img.gif
folder2/img2.gif
folder3/img3.gif

I want to extract the image files without the folder hierarchy so the extracted result looks like:

/img.gif
/img2.gif
/img3.gif

I need to do this with a combination of Unix and PHP. Here is what I have so far, it works to extract them to the specified directory but keeps the folder hierarchy:

exec('gtar --keep-newer-files -xzf images.tgz -C /home/user/public_html/images/',$ret);
Edit
Report