比如下面是某个使用JPgraph生成图片的文件:jp.php
<?php
include ("../jpgraph.php");
include ("../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,"auto");
$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();
?>我们都知道在其他页面使用<img src="jp.php"/>就可以显示这个图片,那么我想在生成这个图片时也把图片保存成jp.jpg或jp.png文件到images文件夹,请问各这要怎么做?

解决方案 »

  1.   

    fopen - file_get_contents - fwrite - fclose
      

  2.   

    楼上说清楚啊 这些函数是操作文件的 我需要的是把jpgraph生成的图片保存为文件
      

  3.   

    图片也是文件,同样可以用文件函数来操作
    或者你可以在类文件内添加一个函数,用imagejpeg等函数输出至文件
      

  4.   

    如果是已有的文件或者自己用image函数创建的图片文件我知道怎么用文件函数操作,但现在需要的是操作一个jpgraph生成的图片,就像我列出的那个文件代码,是使用jpgraph输出图片的php文件,怎样才能将输出的图片保存呢??
      

  5.   

    // Stroke the graph
    // $aStrokeFileName If != "" the image will be written to this file and NOT
    // streamed back to the browser
    function Stroke($aStrokeFileName="") {所以
    $graph->Stroke("/tmp/test1.png");