Copy specific files to a ZIP file in DrupalCopy specific files to a ZIP file in Drupal

<?php

// Increase the time limit for closing large zip files.
drupal_set_time_limit(300);

$dir 'sites/default/files/test';
$target_directory 'sites/default/files';
$name 'tmp-archive';

$files file_scan_directory($dir'/.*\.html$/');
$archive_uri $target_directory '/' $name '.zip';

$zip = new ZipArchive();
if (
$zip->open($archive_uriZipArchive::CREATE) === TRUE) {
  foreach (
$files as $file) {
    
$file_root explode('/'$file->uri);
    for (
$j 0$j 3$j++) {
      unset(
$file_root[$j]);
    }
    
$file_dest implode('/'$file_root);
    
$zip->addFile(drupal_realpath($file->uri), $file_dest);
  }
}

$zip->close();


?>

Snippets Tags: 

Reactie toevoegen

Ververs Geef de karakters in die u in de afbeelding ziet. Type the characters you see in the picture; if you can't read them, submit the form and a new image will be generated. Not case sensitive.  Switch to audio verification.