[UPHPU] download of dynamically generated PDF

Wade Preston Shearer wadeshearer.lists at me.com
Sat Feb 12 19:11:04 MST 2011


Right.

Here's an example of the idea (not my code, but it's the same concept):

$gotten = @mysql_query("select * from pdf order by pid desc limit 1");
$row = @mysql_fetch_assoc($gotten);
$bytes = $row[imgdata];
header("Content-type: application/pdf");
header('Content-disposition: attachment; filename="thing.pdf"');
print $bytes;


This works in all browsers but IE.


On Feb 12, 2011, at 05:14 PM, Sean Thayne <sean at exit12.org> wrote:

http://www.php.net/header

// We'll be outputting a PDF
header('Content-type: application/pdf');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');

- Sean


On Sat, Feb 12, 2011 at 6:08 PM, <wadeshearer.lists at me.com> wrote:
I have a server that is dynamically generating a PDF as a string of bytes. Initiating a download and sending the bytes out to the buffer works in all browsers except IE (of course). In IE, the file cannot be read because it's corrupted. My experience with downloading files via a script is that it's a delicate science, but I was able to construct a script a few years ago that has the right combination of headers and server settings such that it works in all browsers. This is the first time I have tried to provide a file download for a file that is generated though (opposed to existing in the file system). Any tips on how to get this to work in IE?

_______________________________________________

UPHPU mailing list
UPHPU at uphpu.org
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net



More information about the UPHPU mailing list