ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  FinanceChart: "save image as" results in a php suffix.
Posted by Stephen on Jul-01-2011 15:42
Hi,
im using Financechart to display a graph.
What i am attempting to do is encode it so that when a user right clicks the png image, the "save image" dialog box displays "chart" with a png suffix for the "Save as type"

no matter what i do (using various examples from the forum) i cannot change the default settings from "financedemohart" as the filename with no entry in the "Save as type" box.

currently, if i save the "image", it is saved as financedemochart.php

how can i code financedemochart.php so i can save the file with a .png suffix??

this is how i am displaying the image at the moment...

header("Content-type: image/png");
$png_image = $c->makeChart2("chart.PNG");
echo $png_image;

thanks
s

  Re: FinanceChart: "save image as" results in a php suffix.
Posted by Peter Kwan on Jul-01-2011 22:51
Hi Stephen,

As according to HTML/HTTP standard, for any URL (such as a web page, an image, etc), the client side filename is set with the "Content-Disposition" attribute.

If you do not set the "Content-Disposition" attribute, the browser is free to choose any name it like. Different browser brands or versions may choose different names. It is possible some browsers will use part of the URL as the filename.

So for your case, please simply add a "Content-Disposition" attribute to specify the client side filename you want to use. For example:

header("Content-Disposition: filename=xxx.png");

Hope this can help.

Regards
Peter Kwan

  Re: FinanceChart: "save image as" results in a php suffix.
Posted by Stephen on Jul-04-2011 19:50
Peter,
Yes it has, thanks, i can now right click and save the image once its been displayed.
But.. before this change i could right click on the displayed png image and go "view image", so only the png image would be displayed in the browser, and then i would right click (again) and go "save image as" - now when i go "view image",  i just get garbage (like the browser no long thinks its a png image and displays the image format as "text")
Anyway around this or is it just a problem with the browser?
Im testing on Firefox 5

thanks
s

  Re: FinanceChart: "save image as" results in a php suffix.
Posted by Stephen on Jul-04-2011 19:58
Peter,
Actually - Forget about this - ive solved it - by going through the php manual on the header command and experimenting.
thanks for the tips, and the fast response.
regards,
s