7 Replies Latest reply on Aug 23, 2012 11:58 AM by james_quiggins

    fms12_cwp_PHP Documentation for getContainerDataURL using HTML embed Tag does not work



      fms12_cwp_PHP Documentation for getContainerDataURL using HTML embed Tag does not work


      FileMaker Server



      Operating system version

      OS X and Windows

      Description of the issue

      The documentation provided by the fms12_cwp_PHP guide for how to utilize the new getContainerDataURL method for files such as PDF's, mp3's, etc. on page 17 (English version) simply does not work.

      $fm=new FileMaker($database, $hostspec, $user, $password);
      $findCommand = $fm->newFindCommand($layout);
      $findCommand->addFindCriterion('type', 'pdf');
      $result = $findCommand->execute();
      $records = $result->getRecords();
      foreach ($records as $record) {
      echo $record->getField('container').'
      // For movies and PDF files, use the HTML embed tag
      echo '
      getContainerDataURL($record->getField('container')) .'">';

      Mostly what I want to get out of this bug report is for FileMaker to provided fully tested documentation, examples, and sample files that work as intended to showcase the new method. I consider this to be a major new feature to the API and the examples should have been updated to use the new code, not provide snippets of code that were assumed to work, which end up with a lot of troubleshooting on the developer's end.

      Steps to reproduce the problem

      1. You have to URL encode the path to the container field. Therefore, the code should look something like:

      echo '
      getContainerDataURL(urlencode($record->getField('container'))) .'">';

      2. The embed tag does not work to display the content for images or files on Firefox 14.0, Safari 5.1.5, or Chrome 20.0. If you point the embed src URL to a valid path to a file stored in the root of your web site it works. However, the getContainerDataURL method is actually returning an XML call to the database as the URL. So I don't believe the embed src likes the path returned by the API. For example, this is what the getContainerDataURL returns:

      Whereas, if you use a path like this, it's fine:

      Of course you can't provide a path to the file stored on the server because FileMaker Server is storing the files outside the root. So Even if you know the actual path to the file you can't use it. I would be interested to know exactly how the WPE is providing a file outside the root to the web server.

      Expected result

      1. The getContainerDataURL method definitely works for externally stored images - jpg, gif, png.

      2. The getContainerDataURL method definitely DOES NOT work for externally stored files - pdf, mp3, .mov, etc.

      3. The example documentation makes it appear as if you no longer need the containerBridge.php file. You still need this file for it to send the correct header based on the file type! I also noticed that the sample code in the API Tutorial is changed very slightly, but uses all the old code. The "new" tutorial files do not use the getContainerDataURL method and the containerBridge.php file has some major omissions to get the getContainerDataURL method to work. User's should still be utilizing the FMS 11 containerBridge.php file if they want the getContainerDataURL method to work correctly.

      Actual result

      1. If you use the embed tag with this method you get either the broken image icon on your web page or the missing plugin icon for files.


      1. There is a work around. However, it's not perfect either. You can use the iframe tag instead of the embed tag. It works fine on Safari and Chrome. I have not gotten around to testing it on IE yet. Firefox on the other hand is a major problem. It requires Acrobat Reader 10 to be installed as well as the PDF Viewer add on (plugin) to be installed. Good luck getting your external web users to have all of that installed! It took me 2 days to figure out why Firefox refused to use iframe. I will have a sample solution posted in the FileMaker section of our web site at formulationspro.com shortly. In the mean time You can try using the following sample code:

      I have a database called PHPExternalContainers with the field ExternalContainer that obviously stores the images and files externally. It uses the containerBridge.php file return the content from the container field — the same as FMS 11 PHP API and earlier.


      // Connect to the database
      require_once ('FileMaker.php');
      $fm = new FileMaker();
      $fm->setProperty('database', 'PHPExternalContainers');
      $fm->setProperty('username', 'Admin');
      $fm->setProperty('password', '1234');

      // Find the record
      $request = $fm->newFindAllCommand('Demo');
      $result = $request->execute();
      $record = $result->getFirstRecord();

      // Display the container as an images.
      echo 'Externally Stored File
      Path: ' . $fm->getContainerDataURL($record->getField('ExternalContainer')) . '
      echo 'getContainerDataURL(urlencode($record->getField('ExternalContainer'))) . '">';

      // Display the container as a file using iframe.
      echo '';

      You still need the containerBridge.php file to process the header correctly for the image or file.


      // Connect to the database
      require_once ('FileMaker.php');
      $fm = new FileMaker();
      $fm->setProperty('database', 'PHPExternalContainers');
      $fm->setProperty('username', 'Admin');
      $fm->setProperty('password', '1234');

      //This is a bridge script that calls FileMaker::getContainerData with the provided url.   
      if (isset($_GET['path'])){
           $url = $_GET['path'];
           $url = substr($url, 0, strpos($url, "?"));
           $url = substr($url, strrpos($url, ".") + 1);
           if($url == "jpg"){
                header('Content-type: image/jpeg');
           else if($url == "gif"){
                header('Content-type: image/gif');
           else if($url == "png"){
                header('Content-type: image/png');
           else if($url == "pdf"){
                header('Content-type: application/pdf');
                header('Content-type: application/octet-stream');
           echo $fm->getContainerData($_GET['path']);


        • 1. Re: fms12_cwp_PHP Documentation for getContainerDataURL using HTML embed Tag does not work

          Hello tduell:

          Thank you for posting.

          I have forwarded your post to our Development and Testing Department. Once more information is made available to me I will update you.


          FileMaker Inc.

          • 2. Re: fms12_cwp_PHP Documentation for getContainerDataURL using HTML embed Tag does not work

            A complete sample database, php files, and technical article that shows how the getContainerDataURL works can be found on our web site in the FileMaker section at:



            • 3. Re: fms12_cwp_PHP Documentation for getContainerDataURL using HTML embed Tag does not work

              We have a similar issue, although we are able to make GetContainerDataURL work without the container bridge, but only when enabling fmxml for the account. However, we then get a password prompt window, which we only can avoid by using the Guest account.

              As far as I know there is nothing in the documentation that states you need XML publishing turned on just for the GetContainerDateURL function to work, and also why you get the password prompt in the browser window. The account and password is supplied in the PHP page.


              Anders Monsen


              • 4. Re: fms12_cwp_PHP Documentation for getContainerDataURL using HTML embed Tag does not work

                Just updated our FMS 12 to, which has the following update for custom web publishing, hopng that it would address the bug with displaying files.

                "Addressed an issue for PHP solutions that use the getContainerDataURL() method to display container data using the HTML object tag. Previously, the issue could cause a web client using Internet Explorer 9 to see PHP errors or HTML errors, or make the Web Publishing Engine unresponsive."

                We still have the exact same problem as posted earlier. This update did not resolve any of the existing problems. This is the only new feature in the API and it still does not work correctly, even after the latest server update that addressed this issue, nor is there any working documentation supplied by FileMaker. I even went so far as to test the HTML object tag to embed images and PDF files on the web page. Every single browser throws errors using the following code with images and PDF files (I wish FileMaker would supply the HTML code they used to validate their work).

                I tried this code with the containerBridge file - No luck. Every browser throws "Plugin Missing" errors for images and PDF's.

                echo '<object data="containerBridge.php?path=' . $fm->getContainerDataURL(urlencode($record->getField('ExternalContainer'))) . '"></object>';


                Then I tried this code without the containerBridge file as per the FileMaker documentation that indicates that you no longer need the containerBridge. The results were even worse, no errors thrown, but absolutley no images or PDF files displayed.

                echo '<object data="' . $fm->getContainerDataURL(urlencode($record->getField('ExternalContainer'))) . '"></object>';


                Since the update was addressing the use of the HTML object tag I didn't try the img or iframe tags to see if they worked or didn't work as a result of being frustrated that even with the server update this new method still doesn't work as expected and no working sample code has been supplied by FileMaker. Until such time that working sample code is available I still stick by my working (work around) code supplied in the earlier posts. Lastly, I did try enabling XML publishing and that did not resolve the problem either.


                Please FileMaker, supply us with the working and validated code you are using to display images and files (PDF, mov, mp3, etc.).

                • 5. Re: fms12_cwp_PHP Documentation for getContainerDataURL using HTML embed Tag does not work

                  Hello tduell:

                  Thank you for responding. 

                  Development and Testing is still investigating this issue. Although quite cryptic I do have some notes from testing.  Testing found that in order to get the code in the documentation working you must first enable the XML privilege.  Testing also noted that they ran into the same browser plugin dependencies you are. The notes state that you can use another HTML tag like href to avoid browser plugin dependencies. Hope that helps.


                  FileMaker Inc. 

                  • 6. Re: fms12_cwp_PHP Documentation for getContainerDataURL using HTML embed Tag does not work

                    I enabled XML publishing on FMS as well as the Privilege Set (Access via XML Web Publishing - FMS only (fmxml)). I still get major problems.


                    1. If I use the suggested HTML href method with the containerBrigde file it downloads the raw source code from the containerBridge file - this is a major security problem. Example code:

                    echo '<a href="containerBridge.php?path=' . $fm->getContainerDataURL(urlencode($record->getField('ExternalContainer'))) . '">file</a>';


                    2. If I use the suggested HTML href method without the containerBridge file it throws the following error - basically that the file cannot be found on the server using the returned XML call.


                    echo '<a href="'. $fm->getContainerDataURL(urlencode($record->getField('ExternalContainer'))) . '">file</a>';


                    Not Found

                    The requested URL /PHPFiles/Advanced/Lesson12//fmi/xml/cnt/test.pdf?-db=PHPExternalContainers&amp;-lay=Demo&amp;-recid=21&amp;-field=ExternalContainer(1) was not found on this server.


                    Not sure if this is a permissions isssue on the server, so I changed the "everone" permissions on the directory from Read Only to Read & Write. That did not resolve the error either. Hopefully that helps in resolving the issue regarding how to get this new method to work with files and not just images. I'm always happy to provide sample code and databases to assist if necessary. Just contact me.

                    • 7. Re: fms12_cwp_PHP Documentation for getContainerDataURL using HTML embed Tag does not work


                      I will forward your comments on to Testing. 


                      FileMaker Inc.