Jump to content

Download Container Data via PHP to local Server

Recommended Posts


we are using a little sync script via php, which allows us to store all data from a FileMaker DB into our internal MySQL-Database. 
The only problem iam unable to solve is how to download images from container fields and store them local on our web server. 

I tried something like:

foreach($recordsPersons as $recordPersonsData) {

          //saving images to /srv/www/htdocs/
          $url_orig = urlencode($recordPersonsData->getField('FotoDatei'));

          // Search for the extension of the file 
          $url = substr($url_orig, 0, strpos($url_orig, "?")); 
          $url = substr($url_orig, strrpos($url_orig, ".") + 1); 

          // Send the correct Content-Type header 
          if($url == "jpg"){ 
              header('Content-type: image/jpeg'); 
          } else if($url == "gif"){ 
              header('Content-type: image/gif'); 
          } else{ 
              header('Content-type: application/octet-stream'); 

          // save file local.
          file_put_contents('/srv/www/htdocs/testfilepicture.jpg', $fm->getContainerData($url_orig));

I was using this reference: http://blog.myfmbutler.com/?p=104

This Code-Snipped works well, but only writes "getContainerData() does not support remote containers" into testfilepicture.jpg..

We are using FileMaker Server 14.

Any Ideas?

Thanks in advance and Cheers

Edited by Marcwa19197

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By Terry Bohach
      Moving from FMP 14 to FMP 17.  
      PHP getValueListTwoFields works on FMP 14. —> 500 error on FMP 17.
      if I comment out the command the page displays just fine.
      I have tried many things nothing works.
      ——- example ——
      $layout =& $fm->getLayout('phpPTRequest');
      $values = $layout->getValueListTwoFields("VLReason");
      foreach($values as $value)
      $VLReason .= '<input name="Reason" type="radio" value="' . $value . '">'. $value .'&nbsp;&nbsp;';           
    • By jstewart30
      Running FMS 13 and trying to run a simple PHP page from my website to access a database, but I'm only getting a blank page.  Not sure if it's a port forwarding issue or a PHP issue, or something else.  If I put my .php file and the includes ("FileMaker.php" file and "FileMaker" folder from the FMS PHP .zip file) in the fmi-test folder on my FM server and access it locally (http://localhost/fmi-test/myphpfile.php), the PHP file works fine and returns data, so I don't think it has any inherent issues, and presumably my FMS is set up correctly.  Putting the same .php file and includes on my web server, though, results in a blank page only.  The includes are in the same directory as the php file itself.  Here's the php file (I've changed the IP address and database names to protect the innocent but they're correct):
      ini_set('display_errors', 1);
      include_once('FileMaker.php');  /* have also used require, include, and require_once with no change */

      $fm = new FileMaker("MyDatabase", "http://myfilemakerserver:8888", "Admin", "");   /*no password*/
      $findCommand = $fm->newFindCommand("MyDatabase");
      $findCommand->addFindCriterion("Phone", "303-555-1234");
      $findCommand->setRange(0, 1);
      $result = $findCommand->execute();
      if (FileMaker::isError($result)) {
      $record = $result->getFirstRecord();
      $name = $record->getField("Customer Name");
      $status = $record->getField("Status");
      echo("$name - $status");
      Infuriatingly I get no errors or feedback, just a blank page when I run this file from my website (but again it works fine locally on the FM server machine). I've confirmed PHP is working on my website as I can do a simple phpinfo() file in the same directory and it runs fine and displays the PHP info.  If I direct a web browser to the same "http://myfilemakerserver:8888" (not the real address obviously, but it is port 8888) I get the "Filemaker Database Server Website" page, so the port forwarding seems to be correct.  I have port 8888 forwarding to port 80 of my FM Server.  I don't have port 443 forwarded to that machine as that's being used for another device on our network, but I assume if I'm not making "https" requests that it should work fine (but maybe that's my problem?).  
      I assume it's just something simple but I've been beating my head against a wall for the better part of the day on this.  Any help would be greatly appreciated.
    • By Martin Taylor
      Hi all experts (hopefully), I have just upgraded from FMS12 to FMS16. On the FMS12 server we are running a php solution. I have installed 16 onto a new server, uploaded all the databases (all successfully running) and have copied the php website to the new location on the 16 server. I can see the website from home (so I know the website is in the right place and the DNS s working) BUT I can't seem to connect to the database successfully. Any help would be much appreciated. Thanks in advance. 
      Oh, and it is accessed with https
    • By Tony Morosco
      I am trying to convert a custom web publishing site in php, from FM Server 12 to FM Server 15.    We've updated the Windows machine that hosts it (to a shared server on the recommendation of IT) and installed FM Server 15.  
      Direct opening of the existing scripts always yields 0 results, though the database hasn't changed.  
      Is there some setting, somewhere, that I am oblivious to?   I've consulted user's manuals, IIS settings, web postings, ...
      Attached is a copy of the website I am running.
      I can point you to the existing website, though I doubt it would be useful.  The beginning part of this website are script tracking errors.  I've been inserting them, trying to track down where this error is creeping up.  So please ignore.
      Please ask any additional questions, I am sure there are many.
    • By Richard Carlton
      PHP VIDEO 2 - Process Walkthrough: https://youtu.be/yAQX0B9Hfyk
      PHP VIDEO 3 - Sample Code Review: https://youtu.be/9thUCa_q_eY
      Download Sample Code: http://fmstartingpoint.com/links/dl_proc.php?idc=CPN_S0067
      Live PHP Page to try out: http://fmstartingpoint.com/links/dl_proc.php?idc=CPN_R0068
      FileMaker CWP Guide: https://fmhelp.filemaker.com/docs/16/en/fms16_cwp_guide.pdf
  • Who Viewed the Topic

    2 members have viewed this topic:
    aztrix55  kolvorok 
  • Create New...

Important Information

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