2014

Jun

3

Av

The other day I showed my teenage daughter a FileMaker Go app I did a few months ago. The app uploads photos from FileMaker Go to a web site and I think it is rather useful. My daughter dismissed me with: “come on dad, there are hundreds of apps doing the same thing!”. She is of course right, but uploading from FileMaker is actually invaluable!

I have implemented the upload process in a couple of cases already and it has turned out to be very valuable to our customers. Imagine you have a FileMaker Go app with work orders and the customer wants to view photos, it could be photos before and after you did your work, daily updates from a construction site, etc. Take a photo, connect it to a customer and upload it from FileMaker Go couldn’t be easier.

For a simple solution you need a container field for the photo, the new function Base64Encode to transform the photo to a string, and the Insert from URL script step to make the upload.

On the server you need a web page which receives and saves the photo on the web server. You also need a web page where the customer logs in and view the photos.

In my small example I have added a field for a comment. The FileMaker Go app looks like this:

FMGoUpload_iphone

When the user clicks New image a new record is created and the user can take a photo. The button Upload runs the script which uploads the image together with the comment and some id numbers to the server, the script is only one line in its simplest form.

It is often unnecessary to upload an image in full resolution, I use the function GetThumbnail to scale the photo to a proper size (below it is max 400 pixels in either direction). The Insert from URL script step is shown below.

FMGoUpload_httppost

Note that I use the httppost prefix to be able to POST data to a web page. Replace URLTOUPLOAD with the url address to your web page. I have added a md5 argument as well with a secret password, not everyone in the whole world should be able to upload photos to the web page. The new GetContainerAttribute function is used to calculate the md5 checksum. (Tips: make the password different every day, combine it with the ids, use the photo, etc.)

I use PHP for the web page, you could use whatever language you want. My favorite framework at the moment is Slim Framework, but the PHP code below is from a CodeIgniter site.

FMGoUpload_PHP

The PHP function base64_decode converts the image back to a viewable photo, and the function file_put_contents saves it in a uploads folder with img_id.png as the name. Make sure the uploads folder is writable. You have to save the id, customer id and comment somewhere else, maybe in a database.

Before the photo is saved I check if the md5 checksum from FileMaker is the same as the md5 checksum calculated on the server. Note that you have to use exactly the same string when calculating the md5 checksum!

When the customer logs in to the web site they will immediately see the uploaded photo.

FMGoUpload_web

Skriv en kommentar

  • (will not be published)
  • + 4 = ten

Läs också: