Background: We're using Google Charts to create graphs of some data generated by our web app. The user creates a report and then emails that report. Trouble is, once the user opens the report in Microsoft Word, that program exhibits some odd behavior regarding the dynamically generated images.
So, using PHP, we want to save our dynamically generated charts on the server, because Word can handle simple linked images without any problems.
I'm kind of at a loss on how to proceed. Ideas?
NO! Your users' computers must have access to https://www.gstatic.com/charts/loader.js in order to use the interactive features of Google Charts.
Google Charts is a cloud-based business intelligence solution designed to help teams visualize data on their websites in the form of pictographs, pie charts, histograms and more.
<?
$imageData = file_get_contents('http://chart.apis.google.com/chart... etc');
// Attach image data as attachment to an email
//OR:
file_put_contents('/path/to/save/image.png',$imageData);
?>
The simplest way is probably to use something like curl
to retrieve the image from Google and write it out to a file on your server. You could also just use fopen
and related functions, if you turn on the allow_url_fopen
option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With