2 Replies Latest reply on Dec 14, 2015 1:09 PM by bill.tucker.la

    FileMaker 11 CWP Get Container method Question


      This question may be a duplicate but I have been unable to locate a suitable answer. First let me provide some context of what I am attempting to do with these images. Each customer has a personalized splash screen image. My goal is download image and display, on the web site, their own splash screen image. 


      So given the context above, I uploaded, to a FileMaker 11 database, a image named berry.png to a FileMaker layout. If I right click the image in the layout for download it saves berry.png to disk. When I connect to the database using PHP API, get the URL from container field, and then execute the getContainer method using the URL from the field it always saved as a JPEG file. My code, below, is very simple.



      $DB_HOST = '';
      $DB_NAME = 'database';
      $DB_USER = 'username';
      $DB_PASS = 'password';

      $fm = new FileMaker($DB_NAME, $DB_HOST, $DB_USER, $DB_PASS);

      $layout = "images_display";
      $documentTitle = "Berry";

      $search = $fm->newFindCommand($layout);
      $search->addFindCriterion("image_name", "==" .$documentTitle);
      $result = $search->execute();

      $record = $result->getFirstRecord();
      $imageUrl = $record->getField("image_field");

      echo "Image URL: " .$imageUrl ."</br>";

      $rawImage = $blogDB->getContainerData($imageUrl);

      When I echo the URL I get an Image URL: /fmi/xml/cnt/data.jpg?-db=Blog&-lay=images_display&-recid=4&-field=image_field(1). When I query the image using the PHP getimagesize() method the mime type it returns is 'image/jpeg' which is expected given the URL. If this question is a duplicate question then please point me to the URL of the discussion or post. If there is a configuration that I have failed to setup then please let me know.

        • 1. Re: FileMaker 11 CWP Get Container method Question

          page 19 of the guide covers using container data:



          In the example you see they're referencing an external file, img.php, using $_GET to pass the image name to get container data. You're trying to do it inline, which should be fine, but it sounds like your query may not be returning what you thought it is.


          Try adding this above your echo to see what's returned.



          That might give you hints as to what is going wrong. Also the API for 11 is very outdated, if you're planning to use it long term, it's been updated to be PHP5+ compatible in version 14


          Another thought is trying a find all to see if the rest of your code is working.

          • 2. Re: FileMaker 11 CWP Get Container method Question

            Hi Mike,


            First let me say thank you for your quick response. Both result (image_field] => Array ( [0] => /fmi/xml/cnt/data.jpg) and record ([image_field] => Array ( [0] => /fmi/xml/cnt/data.jpg) show a data.jpg in the URL and I think your link may have actually answered the question with the following bullet item:


            If your database contains graphics in formats other than GIF or JPEG, the Web Publishing Engine creates a temporary JPEG image when a web browser requests the graphic data.


            So I have to guess if I push a JPEG or GIF to the database I can get my image back in those formats using the PHP API. However, if I push a PNG to the database then it will serve up JPEG. That is of course if I understand it correctly. So the bottom line it does not seem possible to load/push a PNG image to the database and retrieve it using the PHP API?