Search code examples
phpphp-ziparchive

Append existing files on zip extraction?


I have my script downloading a zip which contains an update which will then extract to a location that holds .m3u files which inside just has lines of links:

1.: http://google.com

2.: http://yahoo.com

etc.

I want it so if the file exists (chart.m3u) then append the files to the existing file. So if the download has 2 files (chart.m3u, pop.m3u) and the file exists in the folder it is meant to extract to, then grab all the data inside lets say (chart.m3u) and save it to the existing file (NOT deleting the existing one).

$zip = new ZipArchive;
$extractPath = "/var/lib/mpd/playlists";
if($zip->extractTo($extractPath) == "true")
{
//Do Stuff
}

Solution

  • Sadly in the end i didnt need this scenario and just had a update phase on start.. Check a file inside the zip, if it contains a number <= to current version then just overwrite the file!