web\Response sendStreamAsFile()

sendStreamAsFile() public method

Sends the specified stream as a file to the browser.

Note that this method only prepares the response for file sending. The file is not sent until send() is called explicitly or implicitly. The latter is done after you return from a controller action.

See also sendFile() for an example implementation.

public $this sendStreamAsFile ( $handle, $attachmentName, $options = [] )
$handle resource

The handle of the stream to be sent.

$attachmentName string

The file name shown to the user.

$options array

Additional options for sending the file. The following options are supported:

  • mimeType: the MIME type of the content. Defaults to 'application/octet-stream'.
  • inline: boolean, whether the browser should open the file within the browser window. Defaults to false, meaning a download dialog will pop up.
  • fileSize: the size of the content to stream this is useful when size of the content is known and the content is not seekable. Defaults to content size using ftell(). This option is available since version 2.0.4.
return $this

The response object itself

throws yii\web\HttpException

if the requested range cannot be satisfied.

doc_Yii
2016-10-30 17:16:24
Comments
Leave a Comment

Please login to continue.