AndyChong

URL Syntax for Access to Container Objects

Discussion created by AndyChong on Feb 23, 2017
Latest reply on Mar 5, 2017 by user19752

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.  

 

Outcomes