ChartDirector Ver 4.0 (Perl Edition)

BaseChart.makeTmpFile


Usage

makeTmpFile(dirname [, imageFormat [, lifeTime ]])

Description

Generates the chart as an image and save it to a temporary file, and automatically remove old files.

This method is designed to support web applications styles where the chart is generated in the HTML page (eg. applications involving clickable charts). In HTML, an image can only be delivered using an <IMG> tag in the page. So after the chart image is created, it needs to be stored in the server temporarily to wait for the browser to retreive it using the <IMG> tag URL.

(An alternative would be to create the chart image when the server receives the <IMG> tag URL request from the browser. In this method, the chart image can be streamed directly to the browser without any temporary storage.)

The makeTmpFile method creates the temporary file in the directory given by dirname. To avoid building up of too many temporary files, the makeTmpFile method will automatically removing all files older than a certain life time (default 600 seconds) in that directory.

If makeTmpFile is unsuccessful, an empty string will be returned. In this case, please check that the temporary directory exists, is readable and writable by the web server anonymous user .

It is highly recommended you use a dedicated directory for storing temporary chart images. The makeTmpFile garbage collection mechanism will remove all files older than a certain life time in that directory. If the directory contains some other files, they may also be removed.

Arguments

ArgumentDefaultDescription
dirname(Mandatory)The directory to store the temporary file and to remove old files.
imageFormatPNGA constant representing the format of the image. Must be one of the pre-defined constants PNG, JPG, GIF, BMP or WMP.
lifeTime600The life time of files in seconds. All files older than lifeTime will be deleted. A negative value disables automatic file removal.

Return Value

The temporary file name (not including the path), or an empty string in case of failure.