Jump to content
Sign in to follow this  
Bailey Kessing

Container fields and the Web

Recommended Posts

We need to be able to upload files to a container field via the web in FM12…is it possible? IWP or PHP?

  • Like 1

Share this post


Link to post
Share on other sites

IWP - not possible (without an add-in like SuperContainer)

PHP - possible with just FileMaker Server

Share this post


Link to post
Share on other sites

Thanks for the information dansmith65

Do you have any sample code that how to upload the file to container field from php ?

Thanks in advance

Share this post


Link to post
Share on other sites

No, I haven't uploaded files via PHP API yet, but I would think there is an example in the documentation that comes with FileMaker Server. I know there is an example of how to view container data, so I assume there is info on how to upload container data.

Share this post


Link to post
Share on other sites

It is possible with SC in 12? I was under the impression that it didn’t work in 12...

Share this post


Link to post
Share on other sites

It is possible with SC in 12? I was under the impression that it didn’t work in 12...

You should check with 360 works to be sure, but I thought it would work with SC via IWP in 12.

Share this post


Link to post
Share on other sites

No, I haven't uploaded files via PHP API yet, but I would think there is an example in the documentation that comes with FileMaker Server. I know there is an example of how to view container data, so I assume there is info on how to upload container data.

I have gone thru the documentation that comes with FileMaker Server, there is no example to save and read the data from container field, even i have referred some online portals too... but there is nothing i get it..

do you have any other option to get the sample code ?

Share this post


Link to post
Share on other sites

I just have only one solution regarding this. Simple copy the file from client machine to webserver and keep the filepath of the file in the database in a field. In this way, here we are not storing the file to database, but containing the path of the file, that can be easily viewed on web. That I have done.

Share this post


Link to post
Share on other sites

No, I haven't uploaded files via PHP API yet, but I would think there is an example in the documentation that comes with FileMaker Server. I know there is an example of how to view container data, so I assume there is info on how to upload container data.

I just checked the documentation that I thought would have an example of this, but couldn't find one. I also didn't see any methods in the API to allow adding a file to a container field. So, it doesn't look like it's possible using just the API after all. On the other hand, there is always a work-around...

As Khurshid Khan mentioned, you could upload the file to the server, and store it's path. Then, if you really want the file in a container field, you could write a script that uses the path to insert all newly uploaded files, then run it on the server at a set interval.

Share this post


Link to post
Share on other sites

damsmith65, you are right. but as you saying that, to execute a script using set interval.... I used to try it, but the problem that I am facing is that, we need an absolute path to store the image, And from the web server we are getting it, using some webaddress like that, http://192.168.2.1/images/..... But it will not work in the database.

Share this post


Link to post
Share on other sites

If your web server is also your FileMaker Server, then you should be able to convert the path to a local file path and use that to import it into a container field (a plug-in may be necessary, but I'm not sure). If your web server is on a different computer than your FM Server then you'd have to get the image from a URL, which would require a plug-in if you are not using FM12.

Share this post


Link to post
Share on other sites

Yes I know that, we need the same machine for both web server and FileMaker server. But in mostly cases, it is not same. Then what I should do in that case.

Share this post


Link to post
Share on other sites

Insert image from web into a container field in Filemaker is not supported by Filemakers PHP API or XML API, which you can read in the documentation.

There are 2 ways of do this;

1) Upload image to a webserver and then show that image from a webviewer from within Filemaker. Use the domain name as server address. This is basically what 360works Super Container do. ( plus some more )

2) Have a robot, that import the files into the container fields.

Share this post


Link to post
Share on other sites

Claus L,

:hyper:Have a robot, that import the files into the container fields. :hair:

Keep these things to yourself. Have your robot and enjoy working with its help only. :yep:

Share this post


Link to post
Share on other sites

Khurshid:

Your comment sounds inappropriate !

My post was meant as a help to ways you could accomplish, what you wish.

Using a robot has been used for years.

I could have written that you should read the documentation and keep your questions to yourself !

However, in a forum like this, we help each other.

I suggest that you rethink your tone in your postings.

Share this post


Link to post
Share on other sites

Claus L,

Could you please tell me that, how can I get help from a robot in FM database. My tone was not like that. Because from the beginning I am using FMForum as my one of the best friends in my professional life. I have done a lot of research on inserting image using PHP in FM directly. If it possible to insert image in container field, in any way, suggest me. other than SuperContainer from 360 works.

Share this post


Link to post
Share on other sites

If you want to insert an image into a container field, you can only do this by using Filemaker Pro client.

If you read Filemaker's documentation for PHP API and XML API and IWP, you will discover that inserting files into a container field is not supported.

You can display images from a container field on web, by using php or iwp.

Using a robot means that you create a Filemaker file with scripts, that will import/insert the file into a container field from a desired path.

You will need to use an upload feature, such as html upload, to a folder on the webserver.

The robot will then insert the image from that webfolder, to the container field.

Some considerations to match filename to newly created record needs to be made.

Robot = Filemaker Robot = Filemaker file, that runs on a computer or the server in a Filemaker Pro client, which runs scripts to automate processes with intervals

Share this post


Link to post
Share on other sites

This is NOT needed for an FM Robot, but cron was mentioned, and I think it's a nifty function so I thought I'd reference it: https://github.com/dansmith65/ooScriptMaster/wiki/Functions#wiki-oosm_ScriptCronAdd

Nowadays, a server-side script scheduled to run at set intervals is a better option than the old method of using an FM Robot.

Khurshid,

All this goes back to my last post (#12), where I said you can write a script that imports files (that were uploaded to the server by your custom php code), into container fields. So, no, you can't directly add an image to a container with just FileMaker, but this is a work-around that does result in an image in a FileMaker Container field.

Share this post


Link to post
Share on other sites

Just to clearify...

Insert file/image is not supported in server scripts.

Thats why you need a robot for this.

Thanks for mentioning, I forgot about that.

Personally, I would prefer using a plug-in on the server to do this in a server-side script, but a robot could do this without a plug-in.

Share this post


Link to post
Share on other sites

Hi, just to add to the discussion that is a bit old now.

On one hand, using a robot is not needed as the (PHP) API allows executing scripts using the PerformScriptCommand, which essentially means that you can control the moment of file uploads. Depending on the filesize and your architecture (input file comes directly from user who is awaiting a responsive system, or you need a save file transaction system) you might want to use a robot/cronjob, but it's not needed as such.

Which then possibly still leaves the problem of actually uploading a file into a container field. I'm not a pro with filemaker scripts, but I know that the opensource BaseElements plugin by Goya (who also create and maintain the RestFM plugin) offers several functions that could be used to either download a file from an URL (webserver) to a container field or that could transform text fields into binary data and store it in a container (see base64 functions). Which essentially means that you would just have to think of which way to go and how secure and interactive you want it to be.
Someone mentioned that it's possible to load files from a system path using a script function. I don't know about that, but mention it to gather some info. But I feel this would not necessarily work when the FM Server and the web-/remote server would be separated, or the former would not allow for separate file transactions.

As a sidenote concerning asynchronous calls, when using a webform you could do an asynchronous file-upload using javascript that again triggers a upload from your webserver to your FM server, which returns a success/error message to your server and from there again to your webfrontend; as originally the upload is asynchronous anyways, the user could be presented with a responsive system indicating activity, and also this means you wouldn't need a robot. 

And if you're not happy with the FM PHP API not offering a direct possibility for loading files into containers, please file an official feature request to filemaker http://www.filemaker.com/company/contact/feature_request.html
Also, if you're not happy with the FM PHP API in general (and think it could do with some refactoring and PSR conformance http://www.php-fig.org/) please also file a request.

Have a nice day!

 

 

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

  • Who Viewed the Topic

    1 member has viewed this topic:
    Bob Minteer 
×

Important Information

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