以下是編寫例子,我想直接返回二進(jìn)制流到客戶端下載文件。
header調(diào)用使用webman的方法,配合ob_start() ob_get_clean()獲取二進(jìn)制內(nèi)容,代碼類似
$fp = fopen(...);
ob_start();
...
fclose(...);
$content = ob_get_clean();
return response($content, 200, [
'Content-Description' => 'File Transfer',
'Content-Type => 'application/vnd.ms-execl',
// 其它header.....
]);