webman 怎么返回文件二进制流到客户端

xiaozhige

以下是编写例子,我想直接返回二进制流到客户端下载文件。
截图

1083 1 0
1个回答

six

header调用使用webman的方法,配合ob_start() ob_get_clean()获取二进制内容,代码类似

$fp = fopen(...);
ob_start();
...
fclose(...);
$content = ob_get_clean();
return response($content, 200, [
    'Content-Description' => 'File Transfer',
    'Content-Type => 'application/vnd.ms-execl',
    // 其它header.....
]);
  • 暂无评论
年代过于久远,无法发表回答
🔝