Streaming file to laravel storage

139 Views Asked by At

I am using JPGraph to generate a graph, the hope is to then save the graph to the file system and point to it in a laravel view. I am attempting to render that view into a PDF later (this is why I'm not generating the chart on the fly).

The problem I am having is I can't figure out how to get the Stream method in JPGraph to save to the Laravel file system.

$graph = new Graph\PieGraph(350, 250);
$graph->title->Set("A Simple Pie Plot");
$graph->SetBox(true);
     
$legends = ['A (%d)','B (%d)','C (%d)','D (%d)','E (%d)',];
$data = array(40, 21, 17, 14, 23);
$p1   = new Plot\PiePlot($data);
        
$p1->SetLegends($legends);

$p1->ShowBorder();
$p1->SetColor('black');
$p1->SetSliceColors(array('#1E90FF', '#2E8B57', '#ADFF2F', '#DC143C', '#BA55D3'));
$graph->legend->SetPos(0.5,0.98,'center','bottom');
$graph->Add($p1);
$image = $graph->img->Stream(/* TO LARAVEL STORAGE */);

I have tried pointing directly to the path using storage_path('images\graphs\test.png'); but I get a permissions error.

0

There are 0 best solutions below