Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5526 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Okay, this might be a little bit complicated. I'm trying to save an image taking from a container field to my local disk. I know it's possible to save a picture to a specific location with PHP but I can't pull it off with a URL that gets an image from the FileMaker database.

That's because I need to insert this pic into a PDF created with TCPDF and TCPDF requires perfect HTML in order to work, meaning calling image.php? makes it fail and tell me image.php? isn't a picture.(I know it's not the exact line).

Now I can't really save the pictures locally and just put a reference to it in the database because the picture in this field can be modified by my clients, and it's important to me that if they change it, the next time they log in my web module, the image on the local will take the last one's place.

Posted

The following will read the image from Filmaker and write a local copy on the fly. I'm assuming image.php is a standard "container bridge" file and RecID is the only parm required to produce a single image from the database. Still, depending on your requirements this could become more trouble than it's worth (see below).


$imgpath = "http://server/path/image.php?RecID=" .$_GET['RecID'];

$img_h = curl_init($imgpath);

curl_setopt($img_h, CURLOPT_RETURNTRANSFER, true);

$imgString = curl_exec($img_h);

$info = curl_getinfo($img_h);

$fh = fopen("./img/img" . $_GET['RecID'] . ".jpg", "w" );

fwrite($fh, $imgString);

curl_close($img_h);

fclose($fh)

The first potential problems that come to mind are large images and several simultaneous hits, but that could hose your PDF gen as well.

As coded it only works with jpegs you can parse out the mime type included in $info['content_type'] to alter the file extension if you want to open it up other image file types, but given that FMP will take just about anything you may still run into trouble.

  • 3 weeks later...
Posted

Well I eventually managed to pulled it off without coming back here and kind of forgot about this thread, but we ended up dropping that for storing the name of the various image on the database and loading the image from the local disk.

(So let's say the database outputs that the database needs to picture 1, 4 and 8, I have about 24 images all number-named to fit what's on the database.

This topic is 5526 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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