Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Download Unknown Container Content [Solution]

Featured Replies

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

}

?>

  • 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?

Depends on code length. In this case though, I'd say file.

Cheers dude ;)

  • 2 weeks later...
  • 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

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.