2017-09-22 6 views
1

내 PHP 코드이Fpdf16은 문제가 무엇인지 를 작동하지 않는 로컬 호스트에 노력하고 있습니다하지만 난 000webhost에 업로드 할 때

<?php 
require_once('lib/fpdf16/fpdf.php'); 
/** 
* Class PDF 
*/ 

require('Functions.php'); 
$function = new Functionality(); 

class PDF extends FPDF 
{ 
    /** 
    * 
    */ 
    /*function Header() 
    { 
     if(!empty($_FILES["file"])) 
     { 
      $uploaddir = "image/logo.jpg"; 
      $nm = $_FILES["file"]["name"]; 
      $random = rand(1,99); 
      move_uploaded_file($_FILES["file"]["tmp_name"], $uploaddir.$random.$nm); 
      $this->Image($uploaddir.$random.$nm,10,10,20); 
      unlink($uploaddir.$random.$nm); 
     } 
     $this->SetFont('Arial','B',12); 
     $this->Ln(1); 
    } 
    function Footer() 
    { 
     $this->SetY(-15); 
     $this->SetFont('Arial','I',8); 
     $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C'); 
    }*/ 

    /** 
    * @param $num 
    * @param $label 
    */ 
    /*function ChapterTitle($num, $label) 
    { 
     $this->SetFont('Arial','',12); 
     $this->SetFillColor(200,220,255); 
     $this->Cell(0,6,"$num $label",0,1,'L',true); 
     $this->Ln(0); 
    }*/ 

    /** 
    * @param $num 
    * @param $label 
    */ 
    /*function ChapterTitle2($num, $label) 
    { 
     $this->SetFont('Arial','',12); 
     $this->SetFillColor(249,249,249); 
     $this->Cell(0,6,"$num $label",0,1,'L',true); 
     $this->Ln(0); 
    }*/ 
} 

/** 
* Handle download tweet in pdf format request... 
*/ 
if(isset($_REQUEST['download-pdf'])){ 
    ob_clean(); 
    $filename='image/temp.pdf'; 
    $screen_name = $_REQUEST['username']; 
    $tweets = $function->generatePDFTweet($screen_name); 
    $columns = array(array("name" => "Tweets","width" => 190)); 
    $pdf = new PDF(); 
    $pdf->AddPage(); 
    //Heading 
    $pdf->SetFont('Times','',20); 
    $pdf->SetTextColor(30); 
    $pdf->Cell(0,3,$screen_name."'s tweet",0,1,'C'); 
    $pdf->Ln(); 
    $pdf->SetFillColor(232, 232, 232); 
    $pdf->SetFont('Arial', 'B', 8); 
    foreach ($columns as $column) 
    { 
     $pdf->Cell($column['width'], 6, strtoupper($column['name']), 1, 0, 'L', 1); 
    } 
    $pdf->Ln(); 
    $pdf->Ln(); 
    $pdf->SetFont('Arial', '', 10); 
    foreach ($tweets as $tweet) 
    { 
     foreach ($columns as $column) 
     { 
      $pdf->MultiCell($column['width'], 6,$tweet['no'].'->'.$tweet['text'], 1); 
     } 
    } 
    $pdf->Output($filename,'F'); 
    header("Content-type: application/pdf"); 
    header("Content-Disposition: attachment; filename=".$screen_name."'s tweet.pdf"); 
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
    readfile($filename); 
    //unlink($filename); 
    exit; 
} 
?> 

Fpdf16 로컬 호스트 작업입니다 작업 만 할 때 내가 000webhost에 업로드되지 않는다 이 코드에서? 로컬 호스트에서 완벽하게 실행됩니다. 실행되지 않는 이유 000webhost 어떻게해야합니까? 나는이 모든 것을 바꾸는 많은 다른 옵션을 시도했지만 그것은 작동하지 않는다. 오류가 표시되는 것은 다음과 같습니다.

%PDF-1.3 3 0 obj <> endobj 4 0 obj <> stream x�mP�N�0��+�Ht�#΃B��7�%�nj�i`�T�{� ����1;��F*�n2ӸYpF�A�`�'`�y� ��` % 9�$ �5.C�b��n���Pqgm��~�����o��o�|T9I��HII(���1�1o1���/��Ry8B?��z9��%8;H)�?e�HqTX��\�)�ǝqB��88gB���`�M�4��������[ho:[�f��4���b�~"��G�Q��wJoMt��i�p��o�̣OW�������Ĭ\墳��_}�~� endstream endobj 1 0 obj <> endobj 5 0 obj <> endobj 6 0 obj <> endobj 7 0 obj <> endobj 2 0 obj << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI] /Font << /F1 5 0 R /F2 6 0 R /F3 7 0 R >> /XObject << >> >> endobj 8 0 obj << /Producer (FPDF 1.6) /CreationDate (D:20170922060509) >> endobj 9 0 obj << /Type /Catalog /Pages 1 0 R /OpenAction [3 0 R /FitH null] /PageLayout /OneColumn >> endobj xref 0 10 0000000000 65535 f 0000000442 00000 n 0000000824 00000 n 0000000009 00000 n 0000000087 00000 n 0000000529 00000 n 0000000627 00000 n 0000000728 00000 n 0000000948 00000 n 0000001023 00000 n trailer << /Size 10 /Root 9 0 R /Info 8 0 R >> startxref 1126 %%EOF 
+0

변경 '텍스트/pdf'를해야/pdf' –

+0

당신에게 @Lawrence Cherone 감사하지만이 같은 오류가 작동하지 않는 것은 –

답변

0

PDF에 대한 올바른 MIME 형식이 응용 프로그램`에 application/pdf

header('Content-type: application/pdf'); 
+0

있다 나는 이걸 바꿨지 만 일하지 않아. @ 마이클 남 –