<?php
$app -> get ( '/download/{id}' , function ( $request , $response , $args ) {
$this -> logger -> info ( "Загрузка файла" ) ;
$file = $this -> files_GW -> getFile ( $args [ 'id' ] ) ;
$url = $this -> settings [ 'upload_folder' ] ;
$url .= $file -> path ;
$url .= $file -> name ;
$response = $response -> withHeader ( 'Content-Disposition' , 'attachment' ) ;
$response = $response -> withHeader ( 'Location' , $url ) ;
return $this -> view -> render ( $response , 'download.html' , $args ) ;
} ) -> setName ( 'download' ) ;
PD9waHAKCiRhcHAtPmdldCgnL2Rvd25sb2FkL3tpZH0nLCBmdW5jdGlvbiAoJHJlcXVlc3QsICRyZXNwb25zZSwgJGFyZ3MpIHsKICAgICR0aGlzLT5sb2dnZXItPmluZm8oItCX0LDQs9GA0YPQt9C60LAg0YTQsNC50LvQsCIpOwoKICAgICRmaWxlPSR0aGlzLT5maWxlc19HVy0+Z2V0RmlsZSgkYXJnc1snaWQnXSk7CgogICAgJHVybD0kdGhpcy0+c2V0dGluZ3NbJ3VwbG9hZF9mb2xkZXInXTsKICAgICR1cmwuPSRmaWxlLT5wYXRoOwogICAgJHVybC49JGZpbGUtPm5hbWU7CgogICAgJHJlc3BvbnNlID0gJHJlc3BvbnNlLT53aXRoSGVhZGVyKCdDb250ZW50LURpc3Bvc2l0aW9uJywgJ2F0dGFjaG1lbnQnKTsKICAgICRyZXNwb25zZSA9ICRyZXNwb25zZS0+d2l0aEhlYWRlcignTG9jYXRpb24nLCAkdXJsKTsKICAgIHJldHVybiAkdGhpcy0+dmlldy0+cmVuZGVyKCRyZXNwb25zZSwgJ2Rvd25sb2FkLmh0bWwnLCAkYXJncyk7Cn0pLT5zZXROYW1lKCdkb3dubG9hZCcpOw==