0

What I want to do is have a new image generated when the page is loaded. I have the random string working, but the image won't generate. If I assign it a normal name, not a variable, it'll generate perfectly fine, permissions are set, etc.. Not exactly sure what to do to get it to create the image

Here's the code that works.

 $chart->render("generated/chart.png");

// But it isn't dynamic, like I want it to be
print "<center><img src=generated/$char.png></center>";

Here's the code that doesn't work. So I had the idea of using a random string generator to make a random name for the image, and just do that.

// random string code
$length = 10;

$randomString = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);



$chart->setTitle("Mini Mood Map");
// THIS is the line giving me problems, I've tried different quotes with no luck

$chart->render(generated/$randomString.png);

// Broken image
print "<center><img src=generated/$randomString.png></center>";

Sorry, I have a bad cold and my heads not on tight tonight. Thanks for all suggestions.

sandorfalot
  • 1,042
  • 1
  • 10
  • 19

1 Answers1

0

Note how the original is quoted:

$chart->render("generated/chart.png");

You need to do the same:

$chart->render("generated/" . $randomString . ".png");
Digital Chris
  • 6,177
  • 1
  • 20
  • 29