I am creating a button, that on click it views the PDF uploaded in the MySQL database in new window
here’s my code:
<?php header('Content-type: application/pdf'); echo $pdf_from_database;
the code seems to work and newtab is started, adope start loading, and then I get an error:
file does not begin with “%pdf-”
Anyone knows how to solve the problem?
you are missing some links here.
- first the pdf files should be stored somewhere on a server.
- what you store in the database is information relative to the pdf file such as a url link to it.
you have a pdf file stored in there called file_DBid_83.pdf
when you make a mysql query to open that file, your query returns $row[‘id’] which is 83 for example
so to open the file you go
header('Content-type: application/pdf'); echo "/pdf/file_DBid_" . $row['id'] . ".pdf";