AnsweredAssumed Answered

Storing files in container php/odbc (PutAs), FM12

Question asked by medioag on Sep 6, 2013
Latest reply on Sep 8, 2013 by steve.winter



We are trying to store binary data (word, pdf etc.) in a FileMaker 12 database hosted on FMS 12 Adv. using ODBC and PHP.

Latest ODBC-driver from FileMaker is installed (on OS X Server).


Retrieving and saving data in/from the database is working just fine, but saving files into a container field will not work.

In the ODBC/JDBC-Guide from FileMaker ( , pages 41-42) it says that it is possible to save a file stream in a container field by using the SQL-command PutAs(field, 'FILE').


Working example for saving text in a container field looks like this:

INSERT INTO dataTable ( FileName, FileType, FileSize, Container ) VALUES ( 'xy.doc', 'word', '99999', 'blabla' )

-> result: record stored


Uploading file and saving insert record:

$fileContents = file_get_contents('pathtofile');

INSERT INTO dataTable ( FileName, FileType, FileSize, PutAs( Container, 'FILE') ) VALUES ( 'xy.doc', 'word', '99999', $fileContents )

-> result: odbc_error : "There is an error in the syntax of the query."


We tried diffrent streaming methods in php (fopen, fread) but non was successful.


Do happen to have a working code snippet at hand?


Thank you.

Regards, Martin



As I am about to submit this post I checked the definition table for the possible types in GetAs/PutAs method and am not sure if it would be possible to store word, excel asf files as well.