Get Image from URL directly into Container?
Micah and crew,
I know I asked you this during beta and you showed me a way to basically do this using a combination of PHP in FM pulling a graphic file to the local disk and then an FM script to import that file, but that is client side only and doesn't work server-side (great example, though!). You mentioned that you might be working on getting the plugin to support pulling images directly into container fields. Has that progressed any further?
Thanks for this great plugin!
David Ethell
Get Image from URL directly into Container?
Hello David,
This is at the top of our list for the next version but we haven't started working on it yet. We'll most likely post a beta version in a couple of months. I know this will be a great feature to have.
Regards,
Micah
Hi Micah, now 1.5 is out
Hi Micah,
now 1.5 is out with the PHP_Execute_To_Container Funktion it would be great if you could provid us with an Example how to get a Image from any URL into Container Field. Looking forward to learn how this could be done. Thank you very much for your Support.
Regards Silvan
Examples
Hello Silvan,
Here's a quick example:
PHP_Execute_To_Container( "echo file_get_contents('http://www.scodigo.com/downloads/test/test.jpg');" ; "My_File.jpg" )You can also check the Testbed_v2.fp7 file for examples of many different file types.
Regards,
Micah
I think I may have something
I think I may have something of a solution to this. Convoluted perhaps, but it works. Here's how we are thinking of doing it in essence:
SmartPill pulls the URL image into a local file on disk using code similar to sample code included with SmartPill. Then we call PHP exec to call to the system which launches a small FP7 file. That file has one script that runs the "local" script needed to save the disk file to a container. The deal is you have to have FileMaker client installed on the FM Server machine which I understand is not really recommended so this is probably not the greatest solution.
I will likely try implementing this soon and post my results here.
Thanks,
David
I think I may have something
That's pretty clever! Seems like it should work. Hmmm, I wonder if you have to be logged into the server in order for the FileMaker client to launch? (what I mean is that FMS runs as a service so you don't have to be logged in).
Regards,
Micah
I think I may have something
Another solution is to use fm_perform_script at the end of your PHP snippet to call a FM script which does an InsertPicture[] of the local file containing the graphic. Since you can pass a parameter (or more than one if you encode it properly), you can pass it the file path of the local image file, the layout, and/or the field name of where the image should go. That way you have just one script to do the import.
Note: due to the way fm_perform_script is called, it will return *immediately* so you can't error check the results of the script so it's best to make this call be the last statement of your PHP snippet.
I've been using this technique to create a pie chart whose image is created via a calculated field. The calculated field contains PHP code that references the pie chart data, so as the data changes, so does the chart, automatically without the need for the user to click on a button to generate the chart.