user1737416 user1737416 - 1 year ago 207
jQuery Question

JQplot - jqplotToImageStr - How to convert the generated string back into a chart

I can create the chart, display it, generate an image and convert the image using jqplotToImageStr which is then posted to another php page.

I want to be able to convert the string back into an image and display it on the php page which I can then convert to pdf. I've tried using this php code

$img = $_POST['hidImage'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
return $data;

(Using modx 2.5.1 in a snippet)

But it doesn't render as an image - the image shows the top and bottom sections of the source code (345 lines in total) that is generated.

I'd really appreciate any help or advice before my sanity finally leaves me :-(

generated output

Answer Source

You need to set headers for the image type. Check this answer for your reference.

header('Content-type: image/png');

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download