6 Replies Latest reply on Oct 30, 2013 8:23 AM by jsorge

    Viewing External (fm12) Containers in CWP

    iamsloper

      Hello friends!

       

      I am trying to view filemaker 12 external containers with a web app. The website uses the filemaker php api.

       

      My code is more or less this (following filemaker's example in the cwp docs):

      <img src="http://'. $fm->getContainerDataURL($record->getField('container')) .'">

       

      The first time i go to this page, a dialog pops up asking for a username and password. If i put in a php enabled privilige set account and password, i will be able to view the image. After i enter the username/password it won't ask me again (not sure how long).

       

      Is this the default behavior for viewing containers on the web? Do users really need to enter a filemaker accountpassword to view containers?

       

      Thanks,

       

      Michael Sloper

      Pre1 Software

        • 1. Re: Viewing External (fm12) Containers in CWP
          Mike_Mitchell

          Michael -

           

          I'm not familiar with that particular method of fetching a container field's contents. I usually use the containerBridge.php file (found in FileMaker Server > Examples > PHP > API Examples folder in your Server installation directory).

           

          However, the fact that it's asking for credentials is a little strange. How are you authenticating into the database (in the include file where the $fm object is instantiated)? Does that account have access to the container field in question?

           

          Mike

           

          Edit: I shouldn't post so fast.   

           

          The command in containerBridge.php is getContainerData, not getContainerDataURL. Perhaps this is the problem?

          • 2. Re: Viewing External (fm12) Containers in CWP
            iamsloper

            Mike,

             

            Thanks for the reply.  The same credentials i use to instantiate the $fm object works for the dialog to view the container.

             

            Usually i create the $fm object in a separate function and pass it around to a different function for a query but i have pulled all that out for this to troubleshoot.

             

            From the FileMaker 12 CustomWebPublishing with PHP Doc, it says to use getContainerData() for container fields embedded in the database and use getContainerDataURL for external containers.

             

            I am wondering, is this the default behavior or am i just doing it wrong? Do i need to create a guest access filemaker account with read-only access to the images table ?

             

            -Michael

            • 3. Re: Viewing External (fm12) Containers in CWP
              Mike_Mitchell

              The two functions serve different purposes. getContainerDataURL() fetches the URL of the container, while getContainerData fetches the container data itself. From the documentation (emphasis added):

               

              "If a container field stores objects externally — that is, if you selected Store container data externally in the Field Options dialog — your PHP code needs to use the getContainerDataURL() method to retrieve a fully qualified URL for the container field object." (page 17)

               

              If you go to page 18 (a bit further down), I think your error is that you're trying to insert the "http://" into your URL. The documentation doesn't do that:

               

              echo '<img src="'.$fm->getContainerDataURL($record->getField('container')) .'">';

               

              Since the getContainerDataURL() method already fetches a fully qualified URL, I suspect the "http://" may be confusing the situation. Have you tried just echoing out the results of getContainerDataURL()? Also, your quotations are a bit off; you probably have that already fixed in the actual source code, though.

               

              Again, I usually don't use this method. I use the containerBridge.php file, which passes the path in. So you may want to look at doing that instead.

               

              HTH

               

              Mike

              • 4. Re: Viewing External (fm12) Containers in CWP
                databuzz

                Hi Michael,

                 

                I'm also trying to get this to work with a PHP web app at the moment using external storage with FMS v12.0v4 - so far I haven't been able to get it to work either, and have seen the password prompt that you refer to. If anyone has been able to get this to work successfully I'd love to hear about the configuration as all I can find is bug reports about the getContainerDataURL() method.

                 

                I've reverted back to using the getContainerData method instead which I have previously used with FMS v11 successfully.

                 

                I'll let you know if I have any breakthoughs.

                 

                regards,

                Andrew

                 

                FileMaker 12/11/10/9/8 Certified Developer

                Databuzz

                - - - - - - - - - - - - - - - - -

                Phone: +61 2 9484 6565

                Mobile: +61 418 468 103

                Email: andrew@databuzz.com.au

                http://www.databuzz.com.au

                • 5. Re: Viewing External (fm12) Containers in CWP
                  jsorge

                  Has anyone gotten this to work? I'm having the same issue, with one difference. My container file isn't stored externally, it's embedded in the data file itself. I'm using getContainerDataURL and it returns a good URL. However when clicking on it, the login popup appears. I'm not sure how to circumvent this.

                   

                  What I'm trying to do is link to files on our website that our customers can download if they want to. I don't want to embed them in a page. Thanks for any help.

                  jared

                  • 6. Re: Viewing External (fm12) Containers in CWP
                    jsorge

                    Hi Andrew,

                    We had a breakthrough on another thread (https://fmdev.filemaker.com/message/128385) to get a workaround in place. Hope you can use it.

                    jared