I have the following code:
$ipaFile= '/path/file.ipa';
$iconFilePath = "Payload/myapp.app/AppIcon40x40@2x.png"; // the pathway to my image file if the ipa file is unzipped.
$iconFile = "AppIcon40x40@2x.png";
$iconSaveFile = '/path/';
$zip = new ZipArchive();
if ($zip->open($ipaFile) === TRUE) {
if($zip->locateName($iconFilePath) !== FALSE) {
$zip->extractTo($iconSaveFile, $iconFile);
}
}
My purpose is to dive into this zipped file and only pull out an image file. The code as is creates a a new image file in the directory I want it to go into (The file it creates has the right name and extension, but it is blank, 0 bytes). If I change $iconFile to iconFilePath then PHP correctly extracts the whole pathway. At the end of the pathway is the file (only the single file is extracted) I want, and it is correctly extracted. However, I don't want the folders preceding the file to be extracted, just the one file.
SO, in summary, I can correctly extract the entire zip archive, I can correctly extract the single file, but the file pathway to get to the file is also extracted, but I CANNOT correctly extract the single file all by itself.
I've done lots of searching on it and I can't spot my error. Thanks for your help.