I don't know why it not work? PHP: $zipPath = $this->getDataFolder($this->getServer()->getDataPath() . "worlds/map.zip"); $zip = new \ZipArchive; $result = $zip->open($zipPath); $zip->extractTo($this->getServer()->getDataPath() . "worlds/"); $zip->close(); This is the error I got: [WARNING] RuntimeException: "ZipArchive::extractTo(): Invalid or uninitialized Zip object" (E_WARNING) in "/exampleplugin/src/Main" at line 57
Now it have another error : [CRITICAL] ClassNotFoundException: "Class exampleplugin\ZipArchive not found" (EXCEPTION) in "/src/spl/BaseClassLoader" at line 144
That's the same. Nothing changed. Maybe because the ZIP file doesn't exist or is corrupted? Try doing PHP: var_dump(is_file($this->getServer()->getDataPath() . "worlds/map.zip"));
Not the same. In one case it was missing parenthesis. In other missing back slash. Punctuation is important in computer languages.
[WARNING] RuntimeException: "ZipArchive:Open(): Empty string as source" (E_WARNING) in "/exampleplugin/src/Main" at line 56 this is the error I got after I try this PHP: $zipPath=var_dump(is_file($this->getServer()->getDataPath() . "worlds/map.zip")); $zip = new \ZipArchive; $result = $zip->open($zipPath); $zip->extractTo($this->getServer()->getDataPath() . "worlds/"); $zip->close();
Same Error [WARNING] RuntimeException: "ZipArchive::extractTo(): Invalid or uninitialized Zip object" (E_WARNING) in "/exampleplugin/src/Main" at line 57
Why did you use var_dump()? var_dump() returns void. I told you to use var_dump(is_file()) to check whether the file exists, not to use it as $zipPath!