src/Beluga/Web/Http/Header.php
public static function SendDownloadHeader( string $file, int $filesize = null )
   {

      // Disable all caching mechanisms
      \header( 'Expires: 0' );
      \header( 'Cache-Control: private' );
      \header( 'Pragma: cache' );

      // The next header let the client download the file
      \header( 'Content-Disposition: attachment; filename="' . \rawurlencode( \basename( $file ) ) . '"' );

      // No we must send the associated content type
      static::SendContentType( MimeTypeTool::GetByFileName( $file ), null );

      // If no file size is defined but the file exists, getting the size.
      if ( empty( $filesize ) && \file_exists( $file ) )
      {
         $filesize = \filesize( $file );
      }

      // If a usable file size is known send the 'Content-Length' HTTP header
      if ( ! empty( $filesize ) )
      {
         \header( 'Content-Length: ' . $filesize );
      }

   }
public static function SendDownloadHeader( string $file, int $filesize = null )
   {

      // Disable all caching mechanisms
      \header( 'Expires: 0' );
      \header( 'Cache-Control: private' );
      \header( 'Pragma: cache' );

      // The next header let the client download the file
      \header( 'Content-Disposition: attachment; filename="' . \rawurlencode( \basename( $file ) ) . '"' );

      // No we must send the associated content type
      static::SendContentType( MimeTypeTool::GetByFileName( $file ), null );

      // If no file size is defined but the file exists, getting the size.
      if ( empty( $filesize ) && \file_exists( $file ) )
      {
         $filesize = \filesize( $file );
      }

      // If a usable file size is known send the 'Content-Length' HTTP header
      if ( ! empty( $filesize ) )
      {
         \header( 'Content-Length: ' . $filesize );
      }

   }
public static function SendDownloadHeader ( string $ file , int $ filesize = null ) { // Disable all caching mechanisms \ header ( 'Expires: 0' ) ; \ header ( 'Cache-Control: private' ) ; \ header ( 'Pragma: cache' ) ; // The next header let the client download the file \ header ( 'Content-Disposition: attachment; filename="' . \ rawurlencode ( \ basename ( $ file ) ) . '"' ) ; // No we must send the associated content type static :: SendContentType ( MimeTypeTool :: GetByFileName ( $ file ) , null ) ; // If no file size is defined but the file exists, getting the size. if ( empty ( $ filesize ) && \ file_exists ( $ file ) ) { $ filesize = \ filesize ( $ file ) ; } // If a usable file size is known send the 'Content-Length' HTTP header if ( ! empty ( $ filesize ) ) { \ header ( 'Content-Length: ' . $ filesize ) ; } }
Sends all HTTP headers required to sending a file download to current client.

Caching will be deactivated.

@param  string $file     Full path to download file. You can also use a file name, but if no file size is
defined the 'Content-Length' HTTP header is not send. (It means the client download
processbar can not show the right ready state percentage.
@param  int    $filesize A optional file size definition. If undefined and $file is not a accessible file
path, the 'Content-Length' HTTP header is not send. (default=NULL)
Sends all HTTP headers required to sending a file download to current client .