I want to open a pdf file that is uploaded by the user in the browser itself. I have already tried all the solutions from the similar thread.. but it keeps showing download popup.
<?php
$filename = $_REQUEST['filename'];
/*echo $filePath = 'upload/register/'.$filename;
if (!file_exists($filePath)) {
echo "The file $filePath does not exist";
die();
}
header('Content-type:application/pdf');
header('Content-disposition: inline; filename="'.$filename.'"');
header('content-Transfer-Encoding:binary');
header('Accept-Ranges:bytes');
readfile($filePath);
*/
/*header("Content-type: application/pdf");
header("Content-Disposition: inline; filename=$filename");
@readfile('upload\register\$filename');*/
/*echo "<iframe src=upload\"register\"$filename\" width=\"100%\" style=\"height:100%\"></iframe>";*/
?>
<!DOCTYPE html>
<html>
<head>
<title>PDF</title>
</head>
<body>
<embed src="upload/register/<?=$filename?>" type="application/pdf" width="100%" height="600px" />
<iframe src="upload/register/<?php echo $filename; ?>" width="90%" height="500px">
</iframe>
</body>
</html>
i have also tried embed tag.. but nothing seems to work and it doesnt open and downloads instead