Bonjour,

J'ai un petit soucis, j'utilise une librairie pi_barcode.php pour la génération du barre code, et fpdf pour pouvoir exploité le code barre et l'imprimer, cependant, j'ai un problème avec la librairie pi_barcode.php, c'est que si je je met mon fichier à la racine du serveur cela marche mais l'enregistrement de l'image se fait à la racine, mais si mon fichier est mis dans un dossier, alors la il veut plus me l'enregistrer mais il me l'affiche tous de même. Donc en gros ce que je voudrai c'est de pouvoir enregistrer l'image générer du barcode dans un dossier spécifique et non à la racine du serveur.

Code pour l'affichage et l'enregistrement du barre code

_cb.php :

require('pi_barcode.php');around around $code = $_GET['c'] ;around around// ***** Création de l'objetaround $objCode = new pi_barcode();around around // ***** Hauteur, [Largeur]around $objCode->setSize(25);around around // ***** Autres argumentsaround $objCode->setText('');around $objCode->hideCodeType();around around around $objCode -> setType('C39');around $objCode -> setCode($code);around //Affichage //around $objCode -> showBarcodeImage();around //Enregistrement//around $objCode->writeBarcodeFile($code . '.png');

Le code ci dessus enregistre l'image à la racine du serveur et si le fichier est uniquement a la racine du serveur.

Si le fichier _cb.php se trouve dans un dossier alors l'enregistrement ne se fait plus, et uniquement l'affichage.

Voici le code, pi_barcode.php

/* Affichage image */around aroundfunction showBarcodeImage()around {around $this->checkCode();around $this->encode();around around if ($this->FILETYPE == 'GIF')around {around Header( "Content-type: image/gif");around imagegif($this->IH);around }around elseif ($this->FILETYPE == 'JPG')around {around Header( "Content-type: image/jpeg");around imagejpeg($this->IH);around }around elsearound {around Header( "Content-type: image/png");around imagepng($this->IH);around }around }around around /**around * Sauvegarde Imagearound */around function writeBarcodeFile($file)around {around $this->checkCode();around $this->encode();around around if ($this->FILETYPE == 'GIF') imagegif($this->IH, $file);around elseif ($this->FILETYPE == 'JPG') imagejpeg($this->IH, $file);around else imagepng($this->IH, $file);around }``

le code ci dessous sont les fonctions appelées pour l'affichage et l'enregistrement du barre code

Merci beaucoup de votre aide !

Aucune réponse