[SOLVED] bar graph

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

bar graph

Post by Joe »

I am fairly new to the image functions used within PHP and I recently got a simple script which creates a .png image of a bar graph showing values and I manipulated it slightly so it reads values from the MySQL database. Now it uses imagepng() but I am not sure how I can save the file on the remote disk or if it is even possible?.

Fullest Regards


Joe
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

remote disk, being on the server, or on the client?

on the server, you can pass the filename parameter of the [php_man]imagepng()[/php_man] function.

If you want to save it on the client, there's allowing them to choose to save it.. and forcing the save dialog box to display. For forcing the download, read the [php_man]header()[/php_man] documentation. For display, you'll need a header call to tell the client you are sending it an png image.
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Code: Select all

$image = imagecreatefrompng("test.png");
imagepng($image);
Adding the above to the code says that the image could not be created because there is errors. I already tried. I am not sure that passing file related functions in an image creation is wise so I am stuck for solutions.
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Never mind I found a solution. Thanks anyway.
Post Reply