Change path of uploaded files in zip I've a form that allow the customer to download every photos that a photograph uploaded before.
Here is my submit form :

 public function submitForm(array &amp;$form, FormStateInterface $form_state)
  {
    $parameters = \Drupal::routeMatch()-&gt;getParameters();
    $shooting = Node::load($parameters-&gt;get('shooting_id'));

    $destination = \Drupal::service('file_system')-&gt;realpath('temporary://');

    $zipname = $destination . '/vos_photos_'.$shooting-&gt;id().'.zip';

    header('Content-Type: application/zip');
    header('Content-disposition: attachment; filename='.$zipname);
    header('Content-Length: ' . filesize($zipname));

    $zip = new \ZipArchive();

    $zip-&gt;open($zipname, constant("ZipArchive::CREATE"));

    foreach ($shooting-&gt;field_shooting_photos as $media) {

      $uri = $media-&gt;entity-&gt;field_media_image-&gt;entity-&gt;uri-&gt;value;
      $file_path = \Drupal::service('file_system')-&gt;realpath($uri);

      // Ajout de chaque fichier dans le zip //
      $zip-&gt;addFile($file_path, $media-&gt;entity-&gt;field_media_image-&gt;entity-&gt;name);

    }

    $zip-&gt;close();

    readfile($zipname);
    exit;

  }


This works great. 
The only problem is when I unzip it, I get var/www/drupalvm/web/sites/defaults/files/{My content}
I would like to just have a simple folder files/{my content} without the long path before, or if it's not possible, simply {my content} when you extract the zip. Thank you
I'm pretty the problem can be solved in the addFile by giving a localname, I just can't figure out how to
I finally found the solution, instead of 

$zip-&gt;addFile($file_path, $media-&gt;entity-&gt;field_media_image-&gt;entity-&gt;name);


I simply put 

$zip-&gt;addFile($file_path, basename($file_path));


and it does the job.