2012-07-28 78 views
0

我正在從數據庫和圖像文件夾中提取圖像。FPDF錯誤:缺少或不正確的圖像文件:images/Photo/sample.jpg

現在如果我沒有在文件夾中的圖像,它給我的錯誤:

FPDF error: Missing or incorrect image file: images/Photo/a.jpg 

我根據mysql數據庫圖像字段排序從目錄中的圖片。

現在我想要的是,如果文件夾中沒有圖像或圖像字段爲空,它不應該把我這個錯誤。而是讓我看看文件夾中已經存在的默認圖像。

我使用的代碼是:

$pict=$row['pict']; 
    $image1 = "images/Photo/$pict"; 
    $pdf->SetX($xaxis); 
    $xaxis=$xaxis-55; 
    $yaxis=$yaxis+7; 

    $pdf->Cell(0,0,$pdf->Image($image1,$xaxis,$yaxis,25,29),0,0,'L',0); 
    $sign=$row['sign']; 
    $image2= "images/Signature/$sign"; 
    $yaxis=$yaxis+35; 
    $pdf->Cell(0,0,$pdf->Image($image2,$xaxis,$yaxis,20,0),0,0,'L',0); 

回答

0

好。我已經做了。

所有我應該做的是:

$pict=$row['pict']; 

    //$xaxis=43'; 

    $pdf->SetX($xaxis1); 

    $pdf->Cell(22,80,'-'.$fia2.' '.$sa,0,0,'L',0); 
    if (empty($pict)) 
    {$image1="images/Photo/blank.jpg";} 
    else {$image1 = "images/Photo/$pict";} 
    $pdf->SetX($xaxis); 
    $xaxis=$xaxis-55; 
    $yaxis=$yaxis+7; 

    $pdf->Cell(0,0,$pdf->Image($image1,$xaxis,$yaxis,25,29),0,0,'L',0); 
    $signs=$row['sign']; 
    if (empty($signs)) 
    {$image2="images/Signature/blank.jpg";} 
    else {$image2 = "images/Signature/$signs";}