Automatically Zip Container Fields in Webdirect

Combining Custom Web Publishing (CWP) with Webdirect is a challenge, but offers a large range of options to the developer not available in Webdirect.  In this instance, Mike Duncan of Soliant uses PHP functions to loop through a found set of FileMaker Webdirect records to combine container field files into a single zip file that downloads automatically at the click of a button:

Say you have several container fields associated with a single record and you want to get all those related files at once. You would like it in one nice, convenient zip file that automatically downloads when you click a button. In the standard interface, you would need to download each file individually. We can do better.

By combining a little Custom Web Publishing (CWP) with WebDirect, we can extend the capabilities and provide some added functionality for our users.

Using the FileMaker API for PHP, we can retrieve all records with container data, zip them all in one archive and automatically have the users web browser download it….

Now the interesting part. PHP already has built in zip functions, seehttp://php.net/manual/en/book.zip.php. All we need to do is feed it some data. To get at the container data, we take advantage of the Base 64 functions in FileMaker. There are two parts to each file, the contents of the file itself, which we get in base 64, and the file name. Both of these are something we can calculate from container data.

Duncan is kind enough to provide a downloadable example file via GitHub, as well.

Warning, this is for developers not afraid to dabble in PHP and CWP. But it is sure is sweet, and is a great example of OMG thinking.

Extending Webdirect: Automatically Zip Container Fields.

Liked Liked
Need FileMaker Development Help? Or to purchase FileMaker Software?
Contact FM Pro Gurus for help