2

I am using Ziparchive to extract information from APK file. (I am using php-apk-parser from github)

While most of the apks works fine some of them breaks with this error "ZipArchive::extractTo(): Invalid or uninitialized Zip object".

I can open same APK file WinRar without any errors. PS: I am running application on Windows server.

File1---->>>>>>>>>>

/* ApkParser use for apk extract to get packag detail */

        $apk = new \ApkParser\Parser($tmpfilepath);

----------->

This Parser calls the Ziparchive and extends its with few functions.

class Archive extends \ZipArchive
{
/**
 * @var string
 */
private $filePath;

/**
 * @var string
 */
private $fileName;


 /**
 * @param bool $file
 * @throws \Exception
 */
public function __construct($file)
{
    if ($file && is_file($file)) {
        $x= $this->open($file);
         if ($x== true) 
         {   
             $target = "C:\out";
             $this->extractTo($target);
             $this->close();

         }
        $this->fileName = basename($this->filePath = $file);
    } else {
        throw new \Exception($file . " not a regular file");
    }

}

Now the Out folder is empty whenever I am getting the error:

Error Image: http://take.ms/Wwv3J

shaharpan
  • 91
  • 8
  • 1
    Add your code. Without this it's harder to help you. – Wolen Dec 29 '17 at 15:23
  • If I try to use Ziparchive::extractTo() it breaks with same Error for this kind of APKs. – shaharpan Dec 29 '17 at 15:34
  • You've provided details of how you handle the upload (irrelevant to the question asked) process the filename (irrelevant to the question asked) and shown us the source code for an class which has a different name than the one you instantiated to handle the file contents. There is little error detection in your code. When I try `$zipArcObj->extractTo('deldir',array('AndroidManifest.xml'))‌​;` I get the file. Try writing a MCVE – symcbean Dec 29 '17 at 16:20
  • ^ That's [ask] and [mcve] – Dave S Dec 29 '17 at 18:29

0 Answers0