1

Been trying to make an application in php to unzip files but am having difficulties with sub directories. When I try to upload a zip file with no subfolders just files/folders it works fine, and a zip file with folder containing no extra folders works just fine. but when the folders contain folders with files the zip doesnt get uploaded. am using PHP 7.4 another example i have found does not work with this version.

.zip1 /files/ works

.zip2 /folder/file works

.zip3 /folder/subfolders/file not working(makes app fail, no errors)

this is the basic code am trying to apply for my application:

//upload to this path
$target_path = "a/1/".$folder."/".$filename;

form request -> $source = $_FILES["zip_file"]["tmp_name"];

            if(move_uploaded_file($source, $target_path)) {
                $zip = new ZipArchive();
                $x = $zip->open($target_path);
                if ($x === true) {
                    $zip->extractTo("a/1/".$folder."");
                    $zip->close();

                    unlink($target_path);
                }
Rick W
  • 75
  • 7

0 Answers0