PHP: streaming remote pdf client for browser

there is a pdf created in an external service, and I would like to transfer the PDF to a browser on my php server during streaming to the client so that I do not need to download the pdf file from the remote file, and then start the download initialization, I just want so that the file is immediately downloaded or transferred to the client requesting it.

+6
source share
1 answer

Assuming the generated pdf is located at http://bar.com/foo.pdf , you can do:

$data = file_get_contents("http://bar.com/foo.pdf"); header("Content-type: application/octet-stream"); header("Content-disposition: attachment;filename=YOURFILE.pdf"); echo $data; 
+12
source

Source: https://habr.com/ru/post/946217/


All Articles