I’m writing a program that fills in a pdf template (using fpdf) then captures a screenshot to preview to the user.
Imagemagick seems to need a existing file in the filesystem to capture the preview image meaning I need to save the pdf to directory.
I followed the directions (found here: Cannot Save File to directory using FPDF) to change permission on the folder to enable me to write to the directory but whenever I run my php page now I get:
I have 755 as the default permission, and since I’m just testing and this folder isn’t particularly mission critical I tried to change to 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
I checked the folder after that error and permission reverts back to 755 and there is not a error_log text file so I’m not sure how to debug this as google reveals server error 500 is a generic catch all.
The hosting service is bluehost.com
Here is the code:
<?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');
The above code works as expected when the permission is on 755 and when the last line is changed to download instead of file save ie:
$pdf->Output(); //OR
$pdf->Output('testdocument.pdf', 'D');
Double checked with Hosting IT.
Such message are happening because changing to any permission level higher than 755 has been disabled at the root level.
Thank you for your patience.