If your application is running on "my_server", just provide the full pathname
(not a URL). For example, if the web server root is /var/www then the path
would be "/var/www/graph.jpg". Of course, the web server process needs to have
create or write permissions to create or overwrite the file. (Which is usually
not a good idea.)
If you are asking about saving a plot to a different (remote) server, I don't
think you can do it like that. First, because you cannot store files over HTTP
URLs (you can read, not write). You would have to use something like an FTP.
Also I don't know if the GD extension to PHP supports remote files. It might
depend on how PHP and the GD extension were built.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Either the 2nd or 3rd. The 1st is not valid because the filename needs to be
quoted.
Remember PHPlot makes you use $plot->SetIsInline(TRUE) - else it will ignore
SetOutputFile.
I recommend using a path with that filename, though. If you are going to run
your PHP script via cron using the command-line version (CLI) of PHP, the
working directory does not change to where the script is located. If you try
this via cron without a path on the output file, it is likely to either fail
because of file permissions, or else the file will end up in an unexpected
directory.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You know you still have to call $plot->DrawGraph() for file output, right?
PHPlot doesn't really do anything at all until DrawGraph() - everything else
is just setup, stores things into the object. That includes SetOutputFile() -
it just remembers the filename you want to write to.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In this function: $plot->SetOutputFile($output_file)
How do I use http://my_server/graph.jpg for
$output_file?
If your application is running on "my_server", just provide the full pathname
(not a URL). For example, if the web server root is /var/www then the path
would be "/var/www/graph.jpg". Of course, the web server process needs to have
create or write permissions to create or overwrite the file. (Which is usually
not a good idea.)
If you are asking about saving a plot to a different (remote) server, I don't
think you can do it like that. First, because you cannot store files over HTTP
URLs (you can read, not write). You would have to use something like an FTP.
Also I don't know if the GD extension to PHP supports remote files. It might
depend on how PHP and the GD extension were built.
Yes I just want to save it to the same directory on the same server. I guess
my question is this?
$plot->SetOutputFile(graph.jpg);
$plot->SetOutputFile('graph.jpg');
$plot->SetOutputFile("graph.jpg");
Which of these do I use?
When I get this working I want to run it as a cron job once an hour so it will
need to overwrite the old image.
Either the 2nd or 3rd. The 1st is not valid because the filename needs to be
quoted.
Remember PHPlot makes you use $plot->SetIsInline(TRUE) - else it will ignore
SetOutputFile.
I recommend using a path with that filename, though. If you are going to run
your PHP script via cron using the command-line version (CLI) of PHP, the
working directory does not change to where the script is located. If you try
this via cron without a path on the output file, it is likely to either fail
because of file permissions, or else the file will end up in an unexpected
directory.
OK here's what I have but it still doesn't work but the screen version
(commented out) works.
What does it do, or not do?
You know you still have to call $plot->DrawGraph() for file output, right?
PHPlot doesn't really do anything at all until DrawGraph() - everything else
is just setup, stores things into the object. That includes SetOutputFile() -
it just remembers the filename you want to write to.
No I didn't know I needed all 3 lines - thanks it works now.
Now on to getting it to run as a cron job.