Code for unziping file I am creating a module for Drupal 8, in which I want to upload and extract zip file to a root directory. Inside moduleSettingsForm.php file, I have a function submitForm(array &amp;$form, FormStateInterface $form_state). I am getting all the values of uploaded file but I am unable to extract the content of file.    

So is there any way to do this in Drupal 8?
Once you have the file uri of the uploaded file, this stops being a Drupal problem and starts being a PHP problem.

You should take a look at SO for a full description.

What you are looking for is this snippet.


$zip = new ZipArchive;
$res = $zip-&gt;open('file.zip'); 
if ($res === TRUE) {
  $zip-&gt;extractTo('/myzips/extract_path/');
  $zip-&gt;close();
}