用于创建 .pdf 文件的 php 代码无法在服务器上运行
我正在使用 PHP 代码创建 .pdf 文件,并在该 .pdf 文件中归档表单值。
在本地主机上,代码工作正常,它创建 .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');
}
}
(其不是完整的代码)
确切的问题是什么?
I am using PHP code for creating .pdf file and I am filing forms values in that .pdf file.
On localhost the code is working fine it creates .pdf ,edit .pdf file ....
But when i am putting same code on another server it's not creating .pdf and edit to......
the code is-
<?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');
}
}
(its not complete code)
What is the exact problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果此代码在本地主机上运行,则可能是您的服务器上的权限问题。
If this code is working on localhost, maybe it's a permission problem on your server.
检查你的 apache 错误日志。 它通常位于
/var/log/apache/error.log
中如果您登录到服务器,输入
并重新加载页面, - 任何错误都会显示在此处。如果您需要帮助诊断它们,请将它们粘贴到此处
Check your apache error log. It's usually located in
/var/log/apache/error.log
if you're logged into your server, type
and reload the page -- any errors will show here. Paste them here if you need help diagnosing them
似乎是权限问题。设置要创建 pdf 文件的目录的权限。
Seems like permission issue. set permission on the directory where the pdf file is expected to create.