Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5
<?php OpenSwoole\Server->sendfile(int $fd, string $filename, int $offset = 0, int $length = 0): bool
The file descriptor of the client to send data to
The path of file to send, if it does not exist false
will be returned
Specify the file offset, you can send data from a certain position of the file, default is 0 which means the whole of the file
Specify the length of the file to send, default is to send the whole of the file
If success, it returns 'true', otherwise it returns false
.
Send large amounts of data or files to the remote TCP connection/socket.
<?php
$server->sendfile($fd, __DIR__ . '/test.jpg');