3

I used this code {from : Unzip a file with php}

$zip = new ZipArchive;
$res = $zip->open('file.zip');
if ($res === TRUE) {
  $zip->extractTo('/myzips/extract_path/');
  $zip->close();
  echo 'woot!';
} else {
  echo 'doh!';
}

but it doesn't work with multi-part zip files. The names of my files are

file.zip
file.z01
file.z02 
This's for example :)

*Note : I can't run shell commands because I use shared hosting {Alternate to PHP exec() function}

  • To my knowledge `ZipArchive` in PHP can make multi-part zip files, but I don't think it has the ability to open one. I would say use the shell, but you've excluded that option. Another option is to simulate linux `cat` with PHP so it merges all files into one file, then it shouldn't be a problem. – Xorifelse Jul 18 '18 at 19:36
  • 1
    @Xorifelse Ok, reopened – RiggsFolly Jul 18 '18 at 19:41
  • @Xorifelse How can I do that ? Does it work in shared hosting? Do you have any link to be my guide? Sorry, because I am beginner and English isn't my tongue... – Mohamed Sallam Jul 18 '18 at 19:47
  • Gotta be honest here, I've looked around a bit couldn't find a direct solution other then merging the files to one file using cat. The [source code of Linux cat](https://git.savannah.gnu.org/cgit/coreutils.git/plain/src/cat.c). I didn't see a PHP function of it in the short while I looked (doesn't mean there isn't any), so.. trial and error and start scripting! (only focus on the part that doesn't use options/modifiers) (or move web host). – Xorifelse Jul 18 '18 at 19:50

0 Answers0