1 Reply Latest reply on Mar 5, 2017 11:19 PM by user19752

    URL Syntax for Access to Container Objects

    AndyChong

      Hi

       

      I am using CWP with FileMaker PHP API, I am trying to get image from container field.

       

      I am using containerBridge.php

      <?php

      /**

      * ContainerBridge.php

      *

      */

      require_once('FileMaker.php');

      include 'dbcon.php';

       

      if (isset($_GET['path'])){

              $url = $_GET['path'];

              $url = substr($url, 0, strpos($url, "?"));

              $url = substr($url, strrpos($url, ".") + 1);

              if($url == "jpg" || $url == "jpeg"){

                  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');

              }

              else{

                  header('Content-type: application/octet-stream');

              }

            }

       

       

      echo $fm->getContainerData($_GET['path']);

      ?>

       

      show.php

      $url = urlencode($record->getField('Profile_Img'));

      <img src='containerBridge.php?path=".$url."'>

       

      But not able to show the image at all.

       

      URL return without urlencode()

      /fmi/xml/cnt/noimg.jpg?-db=DB_A01&-lay=PHP_02_APPLICANT&-recid=41&-field=Profile_Img(1)

       

      I also try to run it directly in the server with

      localhost/fmi/xml/cnt/noimg.jpg?-db=DB_A01&-lay=PHP_02_APPLICANT&-recid=41&-field=Profile_Img(1)

      It return 404

      FileMaker Server has encountered an error:

      The requested resource is not available.

       

      Server

      PHP is enable

      XML is enable

       

      Login that I use have the privilege of php and xml

       

      Container field store as external(open)

       

      I don't know what is missing.

      I have another server Implementing the samething, and it work perfectly.  

       

        • 1. Re: URL Syntax for Access to Container Objects
          user19752

          getField() encodes special chars regardless of field type, so you'd need another function as

           

          $url = urlencode($record->getFieldUnencoded('Profile_Img'));

           

          But it looks both worked. getContainerData() seems allowing invalid URL. (like -db=filename&amp;-lay=...)

           

          Does the record have "noimg.jpg" as content?

           

          Your show.php is quoted too short but if there is no line between the 2, it is incorrect.

          $url = urlencode($record->getField('Profile_Img'));

          //here should be echo command with starting quote...

          <img src='containerBridge.php?path=".$url."'>