3 Replies Latest reply on Sep 8, 2013 8:18 AM by steve.winter

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




      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 (http://www.filemaker.com/support/product/docs/12/fmp/fm12_odbc_jdbc_guide_en.pdf , 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.