I just installed the image-barcode Package, but now I have a few
problems using it.
When I run the following code (http://localhost/test.php):
<?php
require_once("Image/Barcode.php");
$bc = new Image_Barcode;
$bc->draw($_GET['bctext'], "Code39", "png");
?>
I get the following error in my browser:
Warning: opendir(C:\php5\pear\Image\Barcode) [function.opendir]: failed
to open dir: Invalid argument in C:\xampp\php\pear\Image\Barcode.php on
line 66
Does anyone perhaps know a solution?
thank you in advance.
Grt,
Kabbi
(Does it have something to do with the: "C:\php5\pear\Image\Barcode" path? ... cause it doesn't exist. It should be "C:\xampp\php\pear\Image\Barcode" I Guess.... isn't it? But does anyone know where I can change / fix this?)
- Code: Select all
$barcodepath = PEAR_INSTALL_DIR . DIRECTORY_SEPARATOR . "Image" . DIRECTORY_SEPARATOR . "Barcode";
$supportedtypes = array();
if ( $incdir = opendir($barcodepath) ) {
while ( false != ( $avaiabletype = readdir($incdir) ) ) {
if ( strstr($avaiabletype, ".php") ) {
$supportedtypes[] = $avaiabletype;
}
}
closedir($incdir);
}
if ( in_array($type . ".php", $supportedtypes) ) {
include_once("Image/Barcode/${type}.php");
} else {
return PEAR::raiseError("$type barcode is not supported");
}
$classname = "Image_Barcode_${type}";
if (!class_exists($classname)) {
return PEAR::raiseError("Unable to include the Image/Barcode/${type}.php file");
}
if (!in_array('draw',get_class_methods($classname))) {
return PEAR::raiseError("Unable to find create method in '$classname' class");
}
@$obj =& new $classname;
$obj->draw($text, $imgtype);
}
}
?>