zanysoft / laravel-zip

MIT License
300 stars 95 forks source link

Add file to zip with custom name #18

Closed NVD-R closed 2 years ago

NVD-R commented 4 years ago

Add file to zip with custom name

zanysoft commented 2 years ago

You add this code in add() function

foreach ( $file_name_or_array as $file_target => $file_name ) {
    $this->addItem($file_name, $file_target, $flatten_root_folder);
}

and then you added this code in addItem function:

private function addItem($file, $file_target = null, $flatroot = false, $base = null) {
  .....
  if (is_null($file_target)) {
        $file_target = is_null($base) ? $real_name : $base.$real_name;
  }
  .....
}

How can null $file_target variable? in this should be set key index if you not set key