fork download
  1. <?php
  2.  
  3. $app->get('/download/{id}', function ($request, $response, $args) {
  4. $this->logger->info("Загрузка файла");
  5.  
  6. $fileModel=$this->filesGW->getFile($args['id']);
  7.  
  8. //XSendFile
  9. $path=Helper::getPathForFile($this->settings['uploadFolder'],$fileModel);
  10. if (file_exists($path)) {
  11. $response = $response->withHeader('X-SendFile', realpath($path));
  12. $response = $response->withHeader('Content-Type','application/octet-stream');
  13. $response = $response->withHeader('Content-Disposition','attachment; filename=' . basename($path));
  14.  
  15.  
  16. }
  17.  
  18. return $response;
  19. })->setName('download');
Runtime error #stdin #stdout #stderr 0.01s 52488KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Notice:  Undefined variable: app in /home/HfmJG9/prog.php on line 3
PHP Fatal error:  Call to a member function get() on null in /home/HfmJG9/prog.php on line 3