繁体   English   中英

尝试将pdf写入文件目录:获取内部服务器错误500

[英]Trying to write a pdf to file directory: Get internal server error 500

我正在编写一个程序,该程序填充pdf模板(使用fpdf),然后捕获屏幕快照以预览给用户。

Imagemagick似乎需要文件系统中的现有文件来捕获预览图像,这意味着我需要将pdf保存到目录。

我按照说明(位于此处: 无法使用FPDF将文件保存到目录 )更改文件夹的权限,以使我能够写入目录,但是每当我现在运行php页面时,我都会得到:

我有755作为默认权限,并且由于我只是在测试,并且此文件夹不是特别重要,因此我尝试将其更改为777。

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,并且没有error_log文本文件,因此我不确定如何调试它,因为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');

经过Hosting IT的仔细检查。

之所以发生这样的消息,是因为在根级别已禁止更改为高于755的任何权限级别。

感谢您的耐心等待。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM