Php 试图将pdf写入文件目录:获取内部服务器错误500
我正在编写一个程序,填充一个pdf模板(使用fpdf),然后捕获一个屏幕截图以预览给用户 Imagemagick似乎需要文件系统中的现有文件来捕获预览图像,这意味着我需要将pdf保存到目录中 我按照说明(在此处找到:)更改了对文件夹的权限,使我能够写入目录,但现在每当我运行我的php页面时,我都会得到: 我有755作为默认权限,因为我只是在测试,这个文件夹不是特别重要,所以我尝试改为777Php 试图将pdf写入文件目录:获取内部服务器错误500,php,imagemagick,fpdf,Php,Imagemagick,Fpdf,我正在编写一个程序,填充一个pdf模板(使用fpdf),然后捕获一个屏幕截图以预览给用户 Imagemagick似乎需要文件系统中的现有文件来捕获预览图像,这意味着我需要将pdf保存到目录中 我按照说明(在此处找到:)更改了对文件夹的权限,使我能够写入目录,但现在每当我运行我的php页面时,我都会得到: 我有755作为默认权限,因为我只是在测试,这个文件夹不是特别重要,所以我尝试改为777 500 Server Error A misconfiguration on the server cau
500 Server Error
A misconfiguration on the server caused a hiccup. Check the server logs, fix the problem, then try again.
URL: *Full URL*
Dangerously writable: [*File path on server*]
FIXED
在出现错误后,我检查了文件夹,权限恢复到755,并且没有错误日志文本文件,因此我不确定如何调试,因为google显示服务器错误500是一个通用的“包罗万象”
托管服务是bluehost.com
代码如下:
<?php
// Library imports
require_once(dirname(__FILE__)."/lib/fpdf/fpdf.php");
require_once(dirname(__FILE__)."/lib/fpdi/fpdi.php");
// End of imports
//OpenCnxn
mysql_connect(*the approrpiate stuff*) or die(mysql_error());
mysql_select_db(*the appropriate stuff*) or die(mysql_error());
//Query DB and calculate number of rows
$query = "Select ProfilePicture from Users where UserID = 1";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
$filename = "template.pdf";
$pdf = new FPDI();
$pdf->AddPage();
// import the template PFD
$pdf->setSourceFile($filename);
// select the first page
$tplIdx = $pdf->importPage(1);
// use the page we imported
$pdf->useTemplate($tplIdx);
//Image insertion
for($i=0;$i<$num_results;$i++){
$row = mysql_fetch_array($result);
$pdf->Image(htmlspecialchars(stripslashes($row['ProfilePicture'])), 13, 13, 35, 25);
}
$pdf->Output('testdocument.pdf', 'F');
仔细检查它的主机 发生此类消息是因为在根级别上已禁用更改为高于755的任何权限级别 谢谢你的耐心
$pdf->Output(); //OR
$pdf->Output('testdocument.pdf', 'D');