<?php
Swoole\Http\Response->sendfile(string $filename, int $offset = 0, int $length = 0)
The file locaiton to be sent. If there is no this file, the sendfile will fail.
The start offset of file to send.
The length of data to send. The default value is the whole length of file.
Send a local file directly to HTTP client with sendfile
.
Before the call of this method, your have to set content type by
$response->header()
.Before the call of this method, your must not call
$response->write
After the call of this method,
$response->end()
is called automatically.
$response->sendfile
doesn't support gzip compression.
<?php
$response->header('Content-Type', 'image/jpeg');
$response->sendfile(__DIR__.$request->server['request_uri']);