src/FileStreamer.php
/**
     * Start serving the file.
     *
     * @return void
     */
Start serving the file.
@return void
Start serving the file . @return void
public function start()
    {
        $fileName = $this->fileInfo->getFilename();
        $this->filePointer = @fopen($this->fileInfo->getPathname(), 'rb');
        if (!$this->filePointer || !flock($this->filePointer, LOCK_SH | LOCK_NB)) {
            throw new RuntimeException("File $fileName is currently not available!");
        }
        $this->disableCompression();
        $this->getRequestedRanges();
        switch (count($this->fileRanges)) {
            case 0:
                $this->sendFile();
                break;
            case 1:
                $this->sendSingleRange();
                break;
            default:
                $this->sendMultipleRanges();
        }
        if (@fclose($this->filePointer) === false) {
            trigger_error("An error occurred while closing file $fileName!", E_USER_WARNING);
        }
        $this->terminate('File served');
    }
public function start ( ) { $ fileName = $ this -> fileInfo -> getFilename ( ) ; $ this -> filePointer = @ fopen ( $ this -> fileInfo -> getPathname ( ) , 'rb' ) ; if ( ! $ this -> filePointer || ! flock ( $ this -> filePointer , LOCK_SH | LOCK_NB ) ) { throw new RuntimeException ( " File  $ fileName  is currently not available! " ) ; } $ this -> disableCompression ( ) ; $ this -> getRequestedRanges ( ) ; switch ( count ( $ this -> fileRanges ) ) { case 0 : $ this -> sendFile ( ) ; break ; case 1 : $ this -> sendSingleRange ( ) ; break ; default : $ this -> sendMultipleRanges ( ) ; } if ( @ fclose ( $ this -> filePointer ) === false ) { trigger_error ( " An error occurred while closing file  $ fileName ! " , E_USER_WARNING ) ; } $ this -> terminate ( 'File served' ) ; }
Start serving the file.
Start serving the file .
// Serving the file finished successfully.