Re: PDF: error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

> Where did you get the $data variable?
> as filesize($data) would return false here, and that's not a good
> value for the Content-Length header :)
Sorry, bad Copy & Paste.

I get it from:
$data = readfile($full);

Result in the browser is:

"%PDF-1.4 %âãÏÓ 351 0 obj <> endobj xref 351 434 0000000016 00000 n
0000010281 00000 n 0000010417 00000 n 0000010574 00000 n 0000010607
00000 n 0000012850 00000 n 0000012884 00000 n 0000013037 00000 n
0000013174 00000 n 0000013704 00000 n 0000014104 00000 n 0000014488
00000 n 0000014700 00000 n 0000014747 00000 n 0000014794 00000 n
0000014842 00000 n 0000014889 00000 n 0000014937 00000 n 0000014984
00000 n 0000015033 00000 n 0000015082 00000 n 0000015130 00000 n
0000015179 00000 n 0000015228 00000 n 0000015277 00000 n 0000015326 "
(etc...)

Full code after my signature.

Any help would be appreciated.
-- 
:wq! Mário Gamito
--

<?php

session_start();

if (isset($_SESSION['email'])) {
 $error = false;
 if (isset($_GET['file'])) {
  $file = basename($_GET['file']);
  $full = '/var/www/testudio.pdf';
  if (!is_readable($full))
   $error = "Invalid filename.";
  } else {
   $error = "No filename given.";
 }

 $data = readfile($full);
 header('Content-type: application/pdf');
 header("Content-Length: " . filesize($data));
 header('Content-disposition: attachment; filename="testudio.pdf"');
 readfile("testudio.pdf");
 }
?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux