2017-06-21 39 views
0

我有一个小问题,我使用库pi_barcode.php生成条形码,并且fpdf能够利用条形码并打印它,但是,我遇到了库pi_barcode问题.php,c'是,如果我把我的文件放在服务器的根目录下,但是图像的记录是在根目录下完成的,但是如果我的文件被放在一个文件夹中,那么它需要更多的保存它但他向我展示了这一切。所以基本上我想要的是能够将图像生成条形码保存在特定的文件夹中,而不是在服务器的根目录下。FPDF && BARCODE

_cb.php:

require('pi_barcode.php'); 

    $code = $_GET['c'] ; 

// ***** Création de l'objet 
     $objCode = new pi_barcode(); 

     // ***** Hauteur, [Largeur] 
     $objCode->setSize(25); 

     // ***** Autres arguments 
     $objCode->setText(''); 
     $objCode->hideCodeType(); 


     $objCode -> setType('C39'); 
     $objCode -> setCode($code); 
     //Affichage // 
     $objCode -> showBarcodeImage(); 
     //Enregistrement// 
     $objCode->writeBarcodeFile($code . '.png'); 

上面的代码图像保存到服务器的根,并且如果该文件是仅在服务器的根。

如果文件_cb.php在一个文件夹中,那么注册不再完成,只有显示器。

下面是代码,pi_barcode.php

/* Show image */ 

function showBarcodeImage() 
     { 
      $this->checkCode(); 
      $this->encode(); 

      if ($this->FILETYPE == 'GIF') 
      { 
       Header("Content-type: image/gif"); 
       imagegif($this->IH); 
      } 
      elseif ($this->FILETYPE == 'JPG') 
      { 
       Header("Content-type: image/jpeg"); 
       imagejpeg($this->IH); 
      } 
      else 
      { 
       Header("Content-type: image/png"); 
       imagepng($this->IH); 
      } 
     } 

     /** 
     * Save Image 
     */ 
     function writeBarcodeFile($file) 
     { 
      $this->checkCode(); 
      $this->encode(); 

      if ($this->FILETYPE == 'GIF')  imagegif($this->IH, $file); 
      elseif ($this->FILETYPE == 'JPG') imagejpeg($this->IH, $file); 
      else        imagepng($this->IH, $file); 
     } 

下面的代码是要求显示和保存条码

非常感谢您的帮助功能!

回答

0

你应该写的完整路径

$objCode->writeBarcodeFile($code . '.png'); 

$path  = '/myfolder/'; 
$filename = 'picture'; 
$objCode->writeBarcodeFile($path.filename. '.png'); 
+0

我所做的更改,并没有改变 – Nosperato

+0

然后你做错了。你目前使用的路径是什么保存文件? – Bernhard