lib/ezfile/classes/ezfile.php
public static function downloadHeaders( $file, $isAttachedDownload = true, $overrideFilename = false, $startOffset = 0, $length = false, $fileSize = false )
    {
        if ( $fileSize === false )
        {
            if ( !file_exists( $file ) )
            {
                eZDebug::writeError( "\$fileSize not given, and file not found", __METHOD__ );
                return false;
            }

            $fileSize = filesize( $file );
        }

        header( 'X-Powered-By: eZ Publish' );
        $mimeinfo = eZMimeType::findByURL( $file );
        header( "Content-Type: {$mimeinfo['name']}" );

        // Fixes problems with IE when opening a file directly
        header( "Pragma: " );
        header( "Cache-Control: " );
        // Last-Modified header cannot be set, otherwise browser like FF will fail while resuming a paused download
        // because it compares the value of Last-Modified headers between requests.
        header( "Last-Modified: " );
        /* Set cache time out to 10 minutes, this should be good enough to work
           around an IE bug */
        header( "Expires: ". gmdate( 'D, d M Y H:i:s', time() + 600 ) . ' GMT' );
        header(
            "Content-Disposition: " .
            ( $isAttachedDownload ? 'attachment' : 'inline' ) .
            ( $overrideFilename !== false ? "; filename={$overrideFilename}" : '' )
        );

        // partial download (HTTP 'Range' header)
        if ( $startOffset !== 0 )
        {
            $endOffset = ( $length !== false ) ? ( $length + $startOffset - 1 ) : $fileSize - 1;
            header( "Content-Length: " . ( $endOffset - $startOffset + 1 ) );
            header( "Content-Range: bytes {$startOffset}-{$endOffset}/{$fileSize}" );
            header( "HTTP/1.1 206 Partial Content" );
        }
        else
        {
            header( "Content-Length: $fileSize" );
        }
        header( 'Content-Transfer-Encoding: binary' );
        header( 'Accept-Ranges: bytes' );
    }
public static function downloadHeaders( $file, $isAttachedDownload = true, $overrideFilename = false, $startOffset = 0, $length = false, $fileSize = false )
    {
        if ( $fileSize === false )
        {
            if ( !file_exists( $file ) )
            {
                eZDebug::writeError( "\$fileSize not given, and file not found", __METHOD__ );
                return false;
            }

            $fileSize = filesize( $file );
        }

        header( 'X-Powered-By: eZ Publish' );
        $mimeinfo = eZMimeType::findByURL( $file );
        header( "Content-Type: {$mimeinfo['name']}" );

        // Fixes problems with IE when opening a file directly
        header( "Pragma: " );
        header( "Cache-Control: " );
        // Last-Modified header cannot be set, otherwise browser like FF will fail while resuming a paused download
        // because it compares the value of Last-Modified headers between requests.
        header( "Last-Modified: " );
        /* Set cache time out to 10 minutes, this should be good enough to work
           around an IE bug */
        header( "Expires: ". gmdate( 'D, d M Y H:i:s', time() + 600 ) . ' GMT' );
        header(
            "Content-Disposition: " .
            ( $isAttachedDownload ? 'attachment' : 'inline' ) .
            ( $overrideFilename !== false ? "; filename={$overrideFilename}" : '' )
        );

        // partial download (HTTP 'Range' header)
        if ( $startOffset !== 0 )
        {
            $endOffset = ( $length !== false ) ? ( $length + $startOffset - 1 ) : $fileSize - 1;
            header( "Content-Length: " . ( $endOffset - $startOffset + 1 ) );
            header( "Content-Range: bytes {$startOffset}-{$endOffset}/{$fileSize}" );
            header( "HTTP/1.1 206 Partial Content" );
        }
        else
        {
            header( "Content-Length: $fileSize" );
        }
        header( 'Content-Transfer-Encoding: binary' );
        header( 'Accept-Ranges: bytes' );
    }
public static function downloadHeaders ( $ file , $ isAttachedDownload = true , $ overrideFilename = false , $ startOffset = 0 , $ length = false , $ fileSize = false ) { if ( $ fileSize === false ) { if ( ! file_exists ( $ file ) ) { eZDebug :: writeError ( "\$fileSize not given, and file not found" , __METHOD__ ) ; return false ; } $ fileSize = filesize ( $ file ) ; } header ( 'X-Powered-By: eZ Publish' ) ; $ mimeinfo = eZMimeType :: findByURL ( $ file ) ; header ( "Content-Type: {$mimeinfo['name']}" ) ; // Fixes problems with IE when opening a file directly header ( "Pragma: " ) ; header ( "Cache-Control: " ) ; // Last-Modified header cannot be set, otherwise browser like FF will fail while resuming a paused download // because it compares the value of Last-Modified headers between requests. header ( "Last-Modified: " ) ; /* Set cache time out to 10 minutes, this should be good enough to work
           around an IE bug */ header ( "Expires: " . gmdate ( 'D, d M Y H:i:s' , time ( ) + 600 ) . ' GMT' ) ; header ( "Content-Disposition: " . ( $ isAttachedDownload ? 'attachment' : 'inline' ) . ( $ overrideFilename !== false ? "; filename={$overrideFilename}" : '' ) ) ; // partial download (HTTP 'Range' header) if ( $ startOffset !== 0 ) { $ endOffset = ( $ length !== false ) ? ( $ length + $ startOffset - 1 ) : $ fileSize - 1 ; header ( "Content-Length: " . ( $ endOffset - $ startOffset + 1 ) ) ; header ( "Content-Range: bytes {$startOffset}-{$endOffset}/{$fileSize}" ) ; header ( "HTTP/1.1 206 Partial Content" ) ; } else { header ( "Content-Length: $fileSize" ) ; } header ( 'Content-Transfer-Encoding: binary' ) ; header ( 'Accept-Ranges: bytes' ) ; }
Handles the header part of a file transfer to the client

@see download()

@param string $file Path to the local file
@param bool $isAttachedDownload Determines weather to download the file as an attachment ( download popup box ) or not.
@param string $overrideFilename Filename to send in headers instead of the actual file's name
@param int $startOffset Offset to start transfer from, in bytes
@param int $length Data size to transfer
@param string $fileSize The file's size. If not given, actual filesize will be queried. Required to work with clusterized files...
Handles the header part of a file transfer to the client