Hi,
Im working on project right now in webdevelopment. im trying to view a PDF file in a browser which is the filepath was stored in database and the actual file save was in folder inside my webfolder and could retrieve/view by its ID. here's some of my code
<?php
if(isset($_POST['search'])){
$con = new PDO("mysql:host=localhost;dbname=qfms","root","");
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);//setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$fid = $_POST['id'];
$stmt = $con->prepare("SELECT filename FROM rabbit_tbl WHERE id= '" .$fid. "'");
$stmt->execute();
while($row = $stmt->fetch()){
header('Content-type: application/pdf');
header("Content-Disposition: inline");
echo "/pdffiles" .$row['id']. ".pdf");
readfile('pdffiles/');
}
}else{
echo "Enter id";
}
?>
My issue here, when i run/compile it, it says "Failed to load PDF document". what am i missing here? do you have any suggestions, tutorial link?
Thanks guys.