用于创建.pdf文件的php代码在服务器上不起作用


php code for creating .pdf file is not working on server

我使用PHP代码创建.pdf文件,并在该.pdf文件中提交表单值。

在localhost上,代码运行良好,它创建了.pdf,编辑了.pdf文件。。。。但当我把相同的代码放在另一台服务器上时,它并没有创建.pdf并编辑为……

代码是-

<?php
date_default_timezone_set('UTC');
require('fpdf/fpdf.php');
class PDF_result extends FPDF {
    function __construct ($orientation = 'P', $unit = 'pt', $format = 'Letter', $margin = 5 ) {
        $this->FPDF($orientation, $unit, $format);
        $this->SetTopMargin($margin);
        $this->SetLeftMargin($margin);
        $this->SetRightMargin($margin);
        //$this->SetRightMargin1($margin1);
        $this->SetAutoPageBreak(true, $margin);
    }
    function Header () {
        //$this->SetLeftMargin(85);
        $this->SetLeftMargin(5);
         $this->Image('header3.jpg',25,15,560);
         $this->SetLeftMargin(25);
    //  $this->SetFont('Arial', 'B', 20);
    //  $this->SetFillColor(36, 96, 84);
    //  $this->SetTextColor(225);
    //  $this->Cell(0, 30, "YouHack MCQ Results", 0, 1, 'C', true);
    }
 function Footer()
{
    //Position at 1.5 cm from bottom
    $this->SetY(-15);
    //Arial italic 8
    $this->SetFont('Arial','I',8);
    //Page number
    $this->Cell(0,10,'ifs , india',0,0,'C');
}

function Generate_Table($subjects, $marks) {
    $this->SetFont('Arial', 'B', 12);
    $this->SetTextColor(0);
//  $this->SetFillColor(94, 188, z);
$this->SetFillColor(94, 188, 225);
    $this->SetLineWidth(1);
    $this->Cell(427, 25, "Subjects", 'LTR', 0, 'C', true);
    $this->Cell(100, 25, "Marks", 'LTR', 1, 'C', true);
    $this->SetFont('Arial', '');
    $this->SetFillColor(238);
    $this->SetLineWidth(0.2);
    $fill = false;
    for ($i = 0; $i < count($subjects); $i++) {
        $this->Cell(427, 20, $subjects[$i], 1, 0, 'L', $fill);
        $this->Cell(100, 20,  $marks[$i], 1, 1, 'R', $fill);
        $fill = !$fill;
    }
    $this->SetX(367);
    //$this->Cell(100, 20, "Total", 1);
//  $this->Cell(100, 20,  array_sum($marks), 1, 1, 'R');
}
}

(其代码不完整)

究竟是什么问题?

如果此代码在localhost上工作,可能是服务器上的权限问题。

检查您的apache错误日志。它通常位于/var/log/apache/error.log

如果您已登录服务器,请键入

tail -f /var/log/apache/error.log

并重新加载页面——任何错误都将显示在此处。如果您需要帮助诊断,请将它们粘贴到此处

似乎是权限问题。对期望创建pdf文件的目录设置权限。