php - view pdf file in browser from mysql database -


i trying retrieve pdf files stored in mysql database , display them in browser. when view button clicked, displaying error: failed load pdf document.

my code follows:

 $query=  mysql_query("select uploaded_file pdf_file id='2'");  header('content-description: file transfer');  header("content-type: application/pdf");  header('content-disposition:inline; filename="'.$query.'"');  @read($query); 

in above code, when view button clicked, file id passed.

you're not using result set....

$result=  mysql_query("select uploaded_file pdf_file id='2'"); $row=mysql_fetch_row($result); $file = $row['uploaded_file']; header("content-type: application/pdf"); @read($file); 

also - i'm not sure why you're want use content-disposition inline. go follows display inline:

header('pragma: public'); header('expires: 0'); header('cache-control: must-revalidate, post-check=0, pre-check=0'); header('content-type: application/pdf'); header('content-transfer-encoding: binary'); header('content-length: '.filesize($file)); @read($file); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -