What are the differences between using "application/octet-stream" and "application/pdf" as the Content-Type header in the PHP script?

When using "application/octet-stream" as the Content-Type header, the browser will treat the response as a generic binary file, prompting the user to download it. On the other hand, using "application/pdf" will tell the browser that the response is a PDF file, allowing it to display the PDF directly in the browser if the browser has a PDF viewer plugin installed. If you want the PDF to be displayed in the browser rather than downloaded, you should use "application/pdf" as the Content-Type header.

<?php
// Set the Content-Type header to display the PDF in the browser
header('Content-Type: application/pdf');
// Output the PDF file content
readfile('path/to/your/file.pdf');