【发布时间】:2019-12-25 23:10:00
【问题描述】:
在使用 Guzzle 6 从 REST API 下载文件时需要帮助。我不希望文件保存在本地,而是从网络浏览器下载。到目前为止的代码,但相信我遗漏了什么吗?
<?php
//code for Guzzle etc removed
$responsesfile = $client->request('GET', 'documents/1234/content',
[
'headers' => [
'Cache-Control' => 'no-cache',
'Content-Type' => 'application/pdf',
'Content-Type' => 'Content-Disposition: attachment; filename="test"'
]
]
);
return $responsesfile;
?>
【问题讨论】: