Download all files from file manager?

Permalink
Hi,

Is there a way to download all files from the file manager? I have run into a database problem and would like to download everything at once in meaningful way (read as, files not buried in series after series of nested folders with file numbers as names...)?

Thanks

 
dimger84 replied on at Permalink Reply
dimger84
Check these 2 Documentation URLs

https://documentation.concrete5.org/developers/working-with-files-an...

https://documentation.concrete5.org/developers/working-with-files-an...

You can create a file list and then create a zip file.

so something like the following

$list = new \Concrete\Core\File\FileList();
$files = $list->getResults();
$zip = new ZipArchive;
$res = $zip->open('/path/to/file.zip', ZipArchive::CREATE);
foreach($files as $f){
  $zip->addFromString($f->getFilename(), $f->getFileContents());
}
$zip->close();
Core::make('helper/file')->forceDownload('/path/to/file.zip');


P.S: In case that you have way too many files maybe you should break this foreach in smaller pieces... for example 40 files pro zip..