May 8, 200817 yr I've just spent the last day and a half figuring out how to use the container bridge to grab any kind of content out of a container field. (users who were only going to drop in images started dropping in pdfs, then someone added a ppt file for good measure). At any rate the container data gets added by one set of users via the FMP client and viewed by another set via the PHP API. Simply adding header('Content-type: application/octet-stream') to all .cnt url references caused Firefox to download the php file and was just ignored by IE. I used PEAR's HTTP_Request Package http://pear.php.net/package/HTTP_Request to come up with the following solution. <?php require_once("FileMaker.php"); require_once('HTTP/Request.php'); $FMServer = "http://myFMserver.myHost.com"; $database = 'myDB'; $user = "username"; $password = "password"; $fm = new FileMaker($database, $FMServer ,$user, $password); $record = $fm->getRecordById("myLayout", $_GET['RecID']); if (FileMaker::isError($record)) { echo "Error: {$record->getMessage()}n"; exit; } $url = $FMServer. $record->getField("myContainer") ; $r = new HTTP_Request($url); $r->setBasicAuth($user, $password); $r->sendRequest(); $httpResponseCode = $r->getResponseCode(); if ( $httpResponseCode == 401 ) { // Handle Unauthorized header("HTTP/1.0 401 Unauthorized"); exit; } elseif ( $httpResponseCode == 404 ) { // Handle File not found header("HTTP/1.0 404 Not Found"); exit; }else { $headers = $r->getResponseHeader(); if (substr($headers['content-disposition'], -3) == "pdf") { //if you want pdfs to show in the browser rather than force download header('Content-Type: application/pdf'); $headers['content-disposition'] = str_replace("attachment", "inline", $headers['content-disposition'] ); }else{ header("Content-type: " . $headers['content-type']); } header("Content-disposition: " . $headers['content-disposition']); header("Content-length: " . $headers['content-length']); print $r->getResponseBody(); } ?>
May 9, 200817 yr Author Thanks. I got it working using cURL as well, but it's part of a lager object I'm writing to handle containers. I'm happy to post the obj when I'm done with it. What's the preference for posting code (between code tags of course) vs. attaching a file?
May 21, 200817 yr Author Sorry this took so long. I kept trying to get it to write. I managed to get cURL to send binary data via a POST but couldn't get Filemaker to take it up. FilemakerContainer.obj.zip
Create an account or sign in to comment