Hello. I am having a hard time in figuring out how to view the pdf file after uploading it in your system. My plan is retrieved PDF files that is stored in mysql database and display them in the browser when the user click the view button. please help me. Currently, here is my code..
<?php
if (isset($_GET['id'])) {
$file = $_GET['id'];
if (file_exists($file) && is_readable($file) && preg_match('/\.pdf$/',$file)) {
header('Content-Type: application/pdf');
header("Content-Disposition: attachment; filename=\"$file\"");
readfile($file);
}
} else {
header("HTTP/1.0 404 Not Found");
echo "<h1>Error 404: File Not Found: <br /><em>$file</em></h1>";
}
?>
it doesn't displaying the pdf file. please help me. thank you..