fmbug Posted August 28, 2012 Posted August 28, 2012 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...
fmbug Posted August 30, 2012 Author Posted August 30, 2012 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.
Deepak Kumar Posted September 3, 2012 Posted September 3, 2012 It is possible through PHP code. :laugh2:
fmbug Posted September 3, 2012 Author Posted September 3, 2012 How is it possible? Can I have the code please?
Claus Lavendt Posted September 3, 2012 Posted September 3, 2012 Insert image files into container fields is not supported by Filemakers PHP API or XML API. Please read documentation on filemaker.com
supernatural Posted September 4, 2012 Posted September 4, 2012 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/
fmbug Posted September 5, 2012 Author Posted September 5, 2012 I know about SuperContainer. I have also worked on that. I need image to be inserted directly into FileMaker.
supernatural Posted September 5, 2012 Posted September 5, 2012 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
Newbies aewerdt Posted January 23, 2015 Newbies Posted January 23, 2015 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.
cbishop Posted November 5, 2019 Posted November 5, 2019 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.
Wim Decorte Posted November 6, 2019 Posted November 6, 2019 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,...)
cbishop Posted November 6, 2019 Posted November 6, 2019 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.
Wim Decorte Posted November 6, 2019 Posted November 6, 2019 Would you exceed 24GB per licensed user per year? That would be a lot... (and container data doesn't count).
cbishop Posted November 6, 2019 Posted November 6, 2019 (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 November 6, 2019 by cbishop
Recommended Posts
This topic is 2099 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 accountSign in
Already have an account? Sign in here.
Sign In Now