By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,719 Members | 1,278 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,719 IT Pros & Developers. It's quick & easy.

displaying a pdf coming out of a mysql-db in a frame

P: n/a
Hi!

I have a mysql-database with some pdf in it.
I can send them to a webbrowser using this script:

<?php
//output.php4
$sql = "SELECT * FROM tbfiles WHERE tbfiles.ID={$id}";
$result = mysql_query($sql);
$dateien = mysql_fetch_object($result);
$daten = $dateien->Inhalt;
$name = $dateien->Dateiname;
$groesse = $dateien->Groesse;
$typ = $dateien->Typ;

header("Content-type: $typ");
header("Content-length: $groesse");
header("Content-Disposition: attachment; filename=$name");
echo $daten;
?>

My problem is that I get a download dialog where I want to save the pdf but
I want to open it in a fram or iframe like this:
<iframe src="./output.php4?id=129" width="100%" height="400"
name="outputbox">
where id=129 indicates my document.

I get the correct result in Internet Explorer (but not in Opera) if I change
the script like this:

header("Content-type: image/jpeg");
header("Content-Disposition: inline; filename=$name");

Does anybody know a solution for Opera? Then I could provide different
scripts depending on the browser.
Or even better a solution working in all browsers?

Thank you very much.

Best wishes

Martin

Jul 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Martin Kirchner wrote:

I have a mysql-database with some pdf in it.
I can send them to a webbrowser using this script:

<?php
//output.php4
$sql = "SELECT * FROM tbfiles WHERE tbfiles.ID={$id}";
$result = mysql_query($sql);
$dateien = mysql_fetch_object($result);
$daten = $dateien->Inhalt;
$name = $dateien->Dateiname;
$groesse = $dateien->Groesse;
$typ = $dateien->Typ;

header("Content-type: $typ");
header("Content-length: $groesse");
header("Content-Disposition: attachment; filename=$name");
echo $daten;
?>

My problem is that I get a download dialog where I want to save the pdf but
I want to open it in a fram or iframe like this:
<iframe src="./output.php4?id=129" width="100%" height="400"
name="outputbox">
where id=129 indicates my document.

I get the correct result in Internet Explorer (but not in Opera) if I change
the script like this:

header("Content-type: image/jpeg");
header("Content-Disposition: inline; filename=$name");


I'd give this a try:

header("Content-type: $typ");
header("Content-Disposition: inline; filename=$name");

No idea whether that'll fix your problem or not though...

Shawn
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 17 '05 #2

P: n/a
Thank you for your answer!
But it doesn't work.
So if anybody has another idea you're welcome!

Best wishes

Martin
Jul 17 '05 #3

P: n/a
Martin Kirchner wrote:
Hi!

I have a mysql-database with some pdf in it.
I can send them to a webbrowser using this script:

<?php
//output.php4
$sql = "SELECT * FROM tbfiles WHERE tbfiles.ID={$id}";
$result = mysql_query($sql);
$dateien = mysql_fetch_object($result);
$daten = $dateien->Inhalt;
$name = $dateien->Dateiname;
$groesse = $dateien->Groesse;
$typ = $dateien->Typ;

header("Content-type: $typ");
header("Content-length: $groesse");
header("Content-Disposition: attachment; filename=$name");
echo $daten;
?>

My problem is that I get a download dialog where I want to save the pdf but
I want to open it in a fram or iframe like this:
<iframe src="./output.php4?id=129" width="100%" height="400"
name="outputbox">
where id=129 indicates my document.

I get the correct result in Internet Explorer (but not in Opera) if I change
the script like this:

header("Content-type: image/jpeg");
header("Content-Disposition: inline; filename=$name");

Does anybody know a solution for Opera? Then I could provide different
scripts depending on the browser.
Or even better a solution working in all browsers?

Thank you very much.

Best wishes

Martin


Here's a link to a clever class file for generating PDF's ... perhaps it
will help you find a solution.

http://www.ros.co.nz/pdf
Jul 17 '05 #4

P: n/a
Doug H wrote:
Martin Kirchner wrote:
Hi!

I have a mysql-database with some pdf in it.
I can send them to a webbrowser using this script:

<?php
//output.php4
$sql = "SELECT * FROM tbfiles WHERE tbfiles.ID={$id}";
$result = mysql_query($sql);
$dateien = mysql_fetch_object($result);
$daten = $dateien->Inhalt;
$name = $dateien->Dateiname;
$groesse = $dateien->Groesse;
$typ = $dateien->Typ;

header("Content-type: $typ");
header("Content-length: $groesse");
header("Content-Disposition: attachment; filename=$name");
echo $daten;
?>

My problem is that I get a download dialog where I want to save the pdf but
I want to open it in a fram or iframe like this:
<iframe src="./output.php4?id=129" width="100%" height="400"
name="outputbox">
where id=129 indicates my document.

I get the correct result in Internet Explorer (but not in Opera) if I
change the script like this:

header("Content-type: image/jpeg");
header("Content-Disposition: inline; filename=$name");

Does anybody know a solution for Opera? Then I could provide different
scripts depending on the browser.
Or even better a solution working in all browsers?


Take a look at www.fpdf.org. We use this pdf creation class in our JAYA123 web
application for small businesses (www.jaya123.com try the demo) . After we
send all the pdf stuff to a file ($fileoutname), the following line seems to
work well at redirection for all browsers.

echo "<HTML><SCRIPT>document.location='$fileoutname ';</SCRIPT></HTML>";

Al C.
__________________________________________________ ________
Adams-Blake Company, Inc.
***
JAYA123 - the web-based total-office system for the
small biz. Order entry, billing, bookkeeping, etc. for $14.95
a month. Perfect for the small business or start-up.
See demo at: http://www.jaya123.com
***
Jul 17 '05 #5

P: n/a
> I have a mysql-database with some pdf in it.
I can send them to a webbrowser using this script:
A short addition: the pdf-files as well as some as docs and pictures are
stored as binaries in the database. Sorry for the misunderstandings.

Bye Martin

I have a mysql-database with some pdf in it.
I can send them to a webbrowser using this script:

<?php
//output.php4
$sql = "SELECT * FROM tbfiles WHERE tbfiles.ID={$id}";
$result = mysql_query($sql);
$dateien = mysql_fetch_object($result);
$daten = $dateien->Inhalt;
$name = $dateien->Dateiname;
$groesse = $dateien->Groesse;
$typ = $dateien->Typ;

header("Content-type: $typ");
header("Content-length: $groesse");
header("Content-Disposition: attachment; filename=$name");
echo $daten;
?>

My problem is that I get a download dialog where I want to save the pdf
but I want to open it in a fram or iframe like this:
<iframe src="./output.php4?id=129" width="100%" height="400"
name="outputbox">
where id=129 indicates my document.

I get the correct result in Internet Explorer (but not in Opera) if I
change the script like this:

header("Content-type: image/jpeg");
header("Content-Disposition: inline; filename=$name");

Does anybody know a solution for Opera? Then I could provide different
scripts depending on the browser.
Or even better a solution working in all browsers?

Thank you very much.

Best wishes

Martin

Jul 17 '05 #6

P: n/a
.oO(Martin Kirchner)
My problem is that I get a download dialog where I want to save the pdf but
I want to open it in a fram or iframe like this:
[...]

Does anybody know a solution for Opera? Then I could provide different
scripts depending on the browser.
Won't work.
Or even better a solution working in all browsers?


There's no solution. Handling downloaded files is completely up to the
client and depends on the user agent's configuration. Some will open a
PDF "inline" if a plugin is available for that and enabled, others will
prompt the download dialog.

Micha
Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.