src/Http/Response.php
/**
	 * Sends a file as the response using a stream. If the file does not exist or lacks read permissions, an exception
	 * will be thrown. Note that this halts the response immediately, and any other output sent with `write()` or
	 * `writeLine()` will be ignored.
	 *
	 * The `$name` parameter is optional and accepts the name of the file to send. When set, the file will forcefully
	 * be downloaded as a binary file, rather than displayed in the browser.
	 *
	 * @param string $path
	 * @param string|null $name
	 * @return void
	 */
Sends a file as the response using a stream. If the file does not exist or lacks read permissions, an exception
will be thrown. Note that this halts the response immediately, and any other output sent with `write()` or
`writeLine()` will be ignored.

The `$name` parameter is optional and accepts the name of the file to send. When set, the file will forcefully
be downloaded as a binary file, rather than displayed in the browser.

@param string $path
@param string|null $name
@return void
Sends a file as the response using a stream . If the file does not exist or lacks read permissions an exception will be thrown . Note that this halts the response immediately and any other output sent with ` write () ` or ` writeLine () ` will be ignored . The ` $name ` parameter is optional and accepts the name of the file to send . When set the file will forcefully be downloaded as a binary file rather than displayed in the browser . @param string $path @param string|null $name @return void
public function sendFile($path, $name = null) {
		if (!@is_readable($path)) {
			throw new Exception(sprintf('Attempt to send file that could not be found or read: %s', $path));
		}
		$handle = @fopen($path, 'r');
		if ($handle === false) {
			throw new Exception(sprintf('Unable to open file for streaming: %s', $path));
		}
		$this->sendFileHandle = $handle;
		$this->sendFileName = $name;
		$this->sendFileSize = filesize($path);
		$this->halted = true;
	}
public function sendFile ( $ path , $ name = null ) { if ( ! @ is_readable ( $ path ) ) { throw new Exception ( sprintf ( 'Attempt to send file that could not be found or read: %s' , $ path ) ) ; } $ handle = @ fopen ( $ path , 'r' ) ; if ( $ handle === false ) { throw new Exception ( sprintf ( 'Unable to open file for streaming: %s' , $ path ) ) ; } $ this -> sendFileHandle = $ handle ; $ this -> sendFileName = $ name ; $ this -> sendFileSize = filesize ( $ path ) ; $ this -> halted = true ; }
Sends a file as the response using a stream.
Sends a file as the response using a stream .