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

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

Recommended Posts

Posted

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...

Posted

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.

Posted

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/

Posted

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

Posted

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
Posted

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...
Posted

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.

Posted

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,...)

Posted

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.

Posted (edited)

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

This topic is 1842 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.