Re: PDF: error

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

 



That's not an error.

That's a PDF in its raw form.

This can happen if you didn't put the right headers.

It can also happen in IE because IE sucks and "memorizes" the
content-type for the URL, so even if you fix it, if you don't close
the whole browser down and start over, it thinks it should be text,
even though your now-correct Content-type is going out...

I suspect maybe control-refresh to force a full reload might fix it,
but quitting IE and starting it again is for sure gonna work on that
one.


On Thu, April 5, 2007 1:46 pm, Mário Gamito wrote:
> 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
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
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