Before start, sorry if this topic is in the wrong place, but i'm new in the forum :S
So,
probably this is the most common error you find when using JpGraph, but even after google for a solution I still get this error...
JpGraph Error: 25111 Can't delete cached image C:\xampp\htdocs\USF\tmp.jpgraph\ima4DA5.tmp. Permission problem?
I already tried to watch over php.ini and I made sure that GD was enabled, I also changed windows 7 security access to the temporary folder where images are saved. But it seems that something misses, any suggestion??
My code is a copy of one used as an example in the official page of JpGraph:
- Code: Select all
<?php
//criar $data
?>
<?php
define('PREFIX_DIR', 'tmp.jpgraph'); // images will be created here
define('PREFIX', 'imagemABC'); // prefix for the images, can be anything
define('TIME_LIMIT', 3 * 60); // 3 minutes
$tmpfname = tempnam(PREFIX_DIR, PREFIX); // create temp filename
?>
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/src/jpgraph.php');
require_once ('jpgraph/src/jpgraph_line.php');
// Some data
$ydata = array(11,3,8,12,5,1,9,13,5,7);
// Create the graph. These two calls are always required
$graph = new Graph(350,250);
$graph->SetScale('textlin');
// Create the linear plot
$lineplot=new LinePlot($ydata);
$lineplot->SetColor('blue');
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
$graph->Stroke($tmpfname);
clean_old_tmp_files();
?>
<img src="<?php echo get_relative_path($tmpfname); ?>">
<?php
#unlink($tmpfname); // wouldn't work correctly
?>
<?php
function get_relative_path($filename)
{
return preg_replace("/^.*\/(".PREFIX_DIR."\/.*)/", "$1", $filename);
}
function clean_old_tmp_files()
{
foreach (glob(PREFIX_DIR.'/'.PREFIX."*") as $filename)
{
#printf ( "Name: %s; age: %d<br>\n", $filename, time() - filemtime($filename) );
$age = time() - filemtime($filename);
if ($age > TIME_LIMIT)
{
unlink($filename);
}
}
}
?>


