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?
Edit: I shouldn't post so fast.
The command in containerBridge.php is getContainerData, not getContainerDataURL. Perhaps this is the problem?
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 ?
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.
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.
FileMaker 12/11/10/9/8 Certified Developer
- - - - - - - - - - - - - - - - -
Phone: +61 2 9484 6565
Mobile: +61 418 468 103
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.