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.

Inserting Image using PHP

Featured Replies

Dear All,

I am working on a project, where I need to insert image in every records using PHP. I have tried in both the ways, by executing script and also by using simple code for php. Please help me. If possible, please tell me the code, which I should use. :(

Thanks in advance...

  • Author

Please tell me or confirm me that It is possible or not. I only want to insert images directly in the FM database using PHP.

It is possible through PHP code. :laugh2:

  • Author

How is it possible? Can I have the code please?

Insert image files into container fields is not supported by Filemakers PHP API or XML API.

Please read documentation on filemaker.com

In PHP, you can't insert file into container. I used this product 360Work SuperContainer. Check out the documentation. It has a section on how to do this in PHP with code sample. You can download a demo. It works great for me

http://www.360works.com/supercontainer/

  • Author

I know about SuperContainer. I have also worked on that. I need image to be inserted directly into FileMaker.

When you upload image using 360Work in PHP, the image is stored in a folder in the FM Server. You have full knowledge of the path where it is being stored. After upload, I execute a FM script to insert this path into the FM record. Thereafter, from FM record , you can access this image because you have the path reference

  • 2 years later...
  • Newbies

I know this thread is old, but I just came across the need to do this today, and thought I would post my workaround here:

 

1. Create a regular form input:

Photo*:<input type="file" name="Photo"></input>

2. On submit, post the file to an ftp server:

$file = $_FILES["Photo"]["name"];
            
$conn_id = ftp_connect("my.server.com",[optional: port number]);
$login_result = ftp_login($conn_id, "user", "password");
ftp_put($conn_id, "remote path" . $file, $_FILES["Photo"]["tmp_name"], FTP_BINARY);
ftp_close($conn_id);

3. Generate the file's URL, and post that to a photoURL field in your FileMaker database:

$photoURL = "ftp://my.server.com/remotepath" . $file;
... $data_array creation ...
$newRequest =& $fm->newAddCommand('databaseName', $data_array);
$result = $newRequest->execute();

4. Create a FileMaker script that uses the "Insert from URL" step to insert the image into the container from your photoURL field. Execute that script:

$newPerformScript = $fm->newPerformScriptCommand('DatabaseName','FileMakerScript');
$scriptResult = $newPerformScript->execute(); 

Some things you may want to do: Validate that file is image, as well as restrict file size. Prevent error from trying to upload a duplicate file name: either automate the deletion of the files from the FTP server, rotate the file names with a counter, etc.

 

  • 4 years later...

There is a workaround for this.  You can Base64Encode your file contents in PHP and then save into a text field in FileMaker - then you can run a FileMaker script to Base64Decode it and store it into a container field.

You can use a global field for the Base64 text contents if you execute the FileMaker script in the same PHP file / connection, and this way it won't take up database storage space.

The Base64encoded version of the file may be bigger than what the alternative is.  The Data API for instance uses the "multi-part upload" mechanism which keeps the upload closer to the actual size the file.

Something to keep in mind if speed is off the essence or the internet connection is poor (low bandwidth, high latency,...)

Yah - the file size will probably grow 25% or more, so totally agree to go with the Data API.  We are holdouts on the PHP API still because of the amount of scripts relying on it, and because our company would probably hit limits and unfairly have to pay for extracting our own on-premise data from the Data API.

Would you exceed 24GB per licensed user per year?  That would be a lot... (and container data doesn't count).

 

Probably.  We have a lot of graphical web views within (and occasionally outside) FileMaker Pro that do a lot of summarization of daily data points, and a quarter of our users are looking at these throughout each day.  They are PHP calls that use an FM script calling ExecuteSQL and returning the results that are then parsed and charted in AMCharts or other software.

We also have several nightly processes that take data out, perform calculations in PHP, and update static summary fields on records (like worked time on an episode and on each episode task).  I'd imagine that we might do between 100GB and 1TB of data transfer in a month through PHP calls, but since we're not logging total output length, I can't say for sure.

Edited by cbishop

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.