I have a PHP web application. I have built a function to download a PDF from an API end point like this:
public function importPdf($id)
{
$resource = fopen('tmp/'.$id.'.pdf', 'w');
$this->client->request('GET', $this->url . '/api/users/' . $id . '/pdf', [
'headers' => [
'Authorization' => "Bearer {$this->accessToken()}",
],
'sink' => $resource,
]);
}
This is calling a Guzzle instance which is working fine and is saving the PDF file to my server. But what I need is for the PDF file to be downloaded to the users browser. If anyone could explain how this can be done I would be grateful.