Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

How to DISPLAY PDF FILE ON A BROWSER

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

How to DISPLAY PDF FILE ON A BROWSER

Postby HUNDU » Fri Oct 25, 2013 3:42 am

Please I'm working how to display pdf on my browser but it is not working this is my code.
I will be grateful with any help.
Thanks in advanced.

<?php
mysql_connect("localhost", "root", "") or die ("Could not save image name Error: " . mysql_error());
mysql_select_db("pdf") or die("Could not select database");
$data = mysql_query("SELECT * FROM pdf2 where id='2'") or
die(mysql_error());
while($row = mysql_fetch_assoc( $data ))
{//Outputs the image and other data
$src=$row['path'];
$file ='http://localhost/pdf/images/';;
$filename =$src; /* Note: Always use .pdf at the end. */

header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');

@readfile($file);
}
?>
HUNDU
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Dec 01, 2010 6:33 am

Re: How to DISPLAY PDF FILE ON A BROWSER

Postby HUNDU » Fri Oct 25, 2013 6:17 am

This is the error message.
This pdf document might not be displayed correctly
HUNDU
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Dec 01, 2010 6:33 am


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron