[owtchart-users] write URL request to a .gif file
Daniel Morissette
dmorissette at dmsolutions.ca
Sat Jan 22 16:24:37 EST 2005
acadeddu at crs4.it wrote:
>
> I'm writing because I want use owtchart to generating graph and
> outputting it in a pdf file. I'm using PHP.
> I'm able to assemble the information into a URL for the online owtchart
> service but I can't save the image in a "tmp" directory as a ".gif
> file", and then print it in a .pdf doc.
> I will be grateful if someone help me to manage, using php script, a
> URL string request like this(http://localhost/cgi-bin/owtchart?
> TYPE=3DBar&VALS=$val&NumPts=5) for fetch image and write it to file.
>
One way to do this could be to use file_get_contents() and
file_put_contents():
<?php
$image_data =
file_get_contents("http://localhost/cgi-bin/owtchart?TYPE=3DBar&VALS=$val&NumPts=5");
$num_bytes_written = file_put_contents("/tmp/test.gif", $image_data);
?>
I didn't test the code above, but I've used variants of that to download
files in the past and according to PHP docs that should do what you want
(requires PHP > 4.3.0 to be binary safe).
Actually, even simpler than that, maybe the copy() function would work:
<?php
copy("http://localhost/cgi-bin/owtchart?TYPE=3DBar&VALS=$val&NumPts=5",
"/tmp/test.gif");
?>
Daniel
--
------------------------------------------------------------
Daniel Morissette dmorissette at dmsolutions.ca
DM Solutions Group http://www.dmsolutions.ca/
------------------------------------------------------------
More information about the OWTChart-users
mailing list