title: How to extract zip file in Laravel 6
body: <p>I am running the latest Laravel 6 and wanting to upload and extract a ZIP file. I tried using the composer chumper/zipper - but seems it not compatible with Laravel 6 yet. So I am trying to use PHP zipArchive.</p>
  
  <p>My code for the proccess I am trying is:</p>
  
  <pre><code>                    $docfileext1 =  $request-&gt;file('czipfile')-&gt;getClientOriginalExtension();
                  $random_filename1 = substr(str_shuffle("abcdefghijklmnopqrstuvwxyz123"), -5);
                  $newfilename1 = $random_filename1.'.'.$docfileext1;
                  //First check this is a ZIP file
                  if ($docfileext1 &lt;&gt; 'zip') {
                      return back(); //-&gt;witherrors('this is not a ZIP file. Please select a zip file');
                  }
  
                  $request-&gt;file('czipfile')-&gt;move(
                      base_path() . '/storage/app/'.$oid.'/courses/'.$inscourse, $newfilename1
                  );
  
                  //Now unzip
                  $target_path = base_path() . '/storage/app/' .$oid. '/courses/'. $inscourse.'/'.$newfilename1;              
                  $extract_path = base_path() . '/storage/app/' .$oid. '/courses/'. $inscourse.'/';
  
  
                  $zip = new ZipArchive();
                  $x = $zip-&gt;open($target_path);
                  if ($x === true) {
                      $zip-&gt;extractTo($extract_path);
                      $zip-&gt;close();
                  }
  </code></pre>
  
  <p>The zip IS succesfully uploading to the correct location. </p>
  
  <p>example of $target_path is <code>/var/www/html/project/storage/app/1/courses/1/random.zip</code></p>
  
  <p>However, I get an error:</p>
  
  <blockquote>
    <p>SplFileInfo::getSize(): stat failed for /tmp/php59z5uT</p>
  </blockquote>
  
  <p>I have checked the php.ini file and the sizes and memory are way higher than the 700kb test zip file I am trying to use.</p>
  
  <p>Which is popping up when I hit the <code>$zip-&gt;open</code> function.</p>
  
  <p>Any ideas on what I am doing wrong here OR is there a better way? Sincerely appreciated.</p>