473,769 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem displaying pdfs from mysql

Hi I have uploaded a pdf file into my db and am trying to display it
again here is the code i have used (at the moment it is just displaying
the binary file's code as text in a html page:

<?php session_start() ;
include("connec tion.php");

$query = "SELECT resource, resource_name FROM tblresources WHERE id =
'3' ";

$result = mysql_query($qu ery) or die(mysql_error () );

$row = mysql_fetch_arr ay($result);
$content = $row['resource'];

header("Content-type: application/pdf");

echo $content;

?>

//am i missing something else to go with header to make it be read as a
pdf file?

Please help!

May 7 '06 #1
5 1588
Rik
monomaniac21 wrote:
header("Content-type: application/pdf");


add:
header('Content-Disposition: attachment; filename="somen ame.pdf"');

should work, BTW directy from
http://nl3.php.net/manual/en/function.header.php

Grtz,
--
Rik Wasmus
May 7 '06 #2
Cheers Rik is that also required for displaying jpgs and stuff? i dont
remember using it.

May 7 '06 #3
Rik
monomaniac21 wrote:
Cheers Rik is that also required for displaying jpgs and stuff? i dont
remember using it.


Not for images, no. Allthough some browsers (I know IE does) display pdf's,
it's not HTML, it's officially not for a browser to handle. Browsers can
display HTML and other "simple" files (for instance XML, TXT, all files
easily made in notepad and the like), and (most) images.

Other files have to be first downloaded and then displayed with other
programs. IE uses an external pdf-reader (normally acrobat), but pretends it
is capable of displaying pdf's by running the program "inline" (for lack of
a better word, my english is limited). Hence the confusion.

That's putting it simple. I'm sure there are people on this ng that DO know
what they are talking about who can correct me, but this explanation has
sufficed for me so far :-)

Grtz,
--
Rik Wasmus
May 7 '06 #4
Rik wrote:
monomaniac21 wrote:

header("Conte nt-type: application/pdf");


add:
header('Conten t-Disposition: attachment; filename="somen ame.pdf"');

should work, BTW directy from
http://nl3.php.net/manual/en/function.header.php

Grtz,

And I've found that you need to use:
header('Content-Disposition: inline; filename="somen ame.pdf"');
.... to display it in the browser

To create a download, save as dialog use:
header('Content-Disposition: attachment; filename="somen ame.pdf"');

--
*************** **************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
The world is my country,
Science, my religion
*************** **************
May 7 '06 #5
Rik
Chuck Anderson wrote:
And I've found that you need to use:
header('Content-Disposition: inline; filename="somen ame.pdf"');
... to display it in the browser

To create a download, save as dialog use:
header('Content-Disposition: attachment; filename="somen ame.pdf"');


As I said, some people do know what they're talking about :-)

Grtz,
--
Rik Wasmus
May 7 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3282
by: Mark | last post by:
Hello, I am new to PERL and I want to do a simple function (in LINUX): find all files that have the extension pseudo.pdf and put the file names in a file; parse the file and change all file names current filename plus date: pseudo+date+.pdf
0
1191
by: billby | last post by:
Hi all, I am trying to solve a problem on a production server, that unfortunately is not repeatable on our development server. It is for a bank, and the site is being hosted by a different company. Anyway the problem is this. There is a directory where a number of pdfs are stored. Here is the structure. bank
0
894
by: Shawn Hogan | last post by:
I'm wondering what my options are for displaying PDFs in my winform. I'd rather not have adobe acrobat reader installed to do this. So far i've looked at adding the pdf.ocx COM component to my application. But i've read that this is unsupported. Any other suggestions? Shawn
14
1956
by: BlueDolphin | last post by:
Hello all. I'm looking for some opinions on using snapshot files or ..pdf for some reports. We are in the initial stages of creating some reports in access that will be pulled online through Cold Fusion. In the past, I have simply created reporting tables with routines that populated the tables overnight. I then use Cold Fusion to output the info online as I wanted it to look. I am in a shop now that wants to use either .pdfs or...
0
1495
by: Scott McFadden | last post by:
My aspx page code reads some custom values from the HTTP headers and then writes a given pdf to the output stream based upon the header values. Unforunately, my code causes IE to pop up an Open / Save dialog instead of invoking the Adobe plugin and displaying the pdf inside of I.E. Here is my code (file points to a valid pdf and mimetype is set to 'application/pdf') private void RenderFile(FileInfo file, string mimeType){ ...
3
1958
by: Mike Kingscott | last post by:
Hi there, I'm writing an app in which a punter buys some PDFs online. After purchasing said PDFs, they will be given a token (bless them Guids) to go to a download .ASPX page from which they can download the PDFs. I'm planning to use Forms Authentication to protect the .ASPX page which gives them the list of PDFs they can download (driven by the token, which will be their order number or similar). The page will also only allow 10...
2
1673
by: donpro | last post by:
Hi, I have a varchar field in a MySQL database that contains a line of text like so: "This is a line if text" The double quotes are included in the database field. I cannot seem to display it on my HTML page, it always shows as blank.
0
1464
by: John Kirkpatrick | last post by:
Hi all, I am having difficulty displaying records on a frontend MS Access 2000 form using a MySQL backend. The following code works well with the Jet database engine but doesn't work properly using the MySQL backend database. All records are displayed on the form using the Jet, but only one record appears using MySQL. Perhaps it just needs some tweaking to work with MySQL. Any advice would be great. Thanks Function HelpDesc(HelpFrm As...
0
777
by: praveenkhade | last post by:
I am working on asp.net ,C#. The pdf files in the grid are displaying properly. The main prob is that in these pdfs one pdf is the main like an index ,if i open this pdf i can link to rest of other pdfs(No need to open rest of the pdfs one by one). The index pdf is opening but its not diverting to that link. (Rest of other pdfs contains individual product information and Index pdf contains list of product .I wnt to click on links in Index...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10212
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10047
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.