1

I have a view-script which opens a pdf-file, it looks like follows:

<?php
$this->title = 'arbeitskalender';
//ini_set('display_errors',1);
header('Content-Type:application/pdf');
header('Content-Disposition', 'attachment; fileName=arbeitskalender.pdf');
readfile('./pdfs/arbeitskalender.pdf');
?>

On my localhost (wamp-server) it works well and the file opens without any error, uploaded to my webspace (not my own server, only a webspace) I get

internal server error

.

What's the problem? Is there a possibility to get a more informative error message? Because it is not my server, I can't have a look in the server log.

pia-sophie
  • 505
  • 4
  • 21

3 Answers3

2

Yes, a lot of:

  • check the network tab in your developer bar. Eventually, turn off (starts the header lines with //) your headers in your script to see the error message (for debugging)
  • check the logfiles of your framework (if you use)
  • check if your application can write log entries
  • enable and display errors (see Showing all errors and warnings)
  • check if php can read the file (permissions and existing of the file)
  • check if you only get the internal server error on this page

Looking to your script:

  • what's $this? I don't see a class definition
  • can php find the file?
Community
  • 1
  • 1
schellingerht
  • 5,726
  • 2
  • 28
  • 56
0

Check ./pdfs/arbeitskalender.pdf permissions. I guess it's not readable for apache user

Mostafa Lavaei
  • 1,960
  • 1
  • 18
  • 27
0

I checked all your suggestions, I learned some more, but couldn't solve the problem. I found another codesnippet which doesn't use readfile and so far this works fine.

<?php
require_once 'Zend/Pdf.php';

header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename=arbeitskalender.pdf');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression','0');
echo file_get_contents("./pdfs/arbeitskalender.pdf");

?>
<html>
<body>
pia-sophie
  • 505
  • 4
  • 21