3 Replies Latest reply on Jun 9, 2014 1:50 PM by philmodjunk

    Uploading pdf, doc, avi, etc.



      Uploading pdf, doc, avi, etc.



           I created a container in the main database, and I want to be able to upload different kinds of files for each record, be it a pdf, doc, video, etc. I understand the option for interactive content, but I do not want to do this method. I also understand setting up the relationship table in the database.
           I want to do it so that when the user drags and drops the file, I would like to see the file's icon and the name of the file as a thumbnail, and when you click it, it either downloads and opens and/or shows up on a new window. 

           Would you guys be able to help me out on this? 


        • 1. Re: Uploading pdf, doc, avi, etc.

               If you do not specify interactive content, drag and drop inserts a physical copy of the file into the container field. But if you have specified external storage for the container field, FileMaker then copies the file to the specified external storage location and keeps a reference to that copy of the file in the container field. If you do not specify external storage, the drag and drop simply leaves the physical copy of the file inserted into the container field.

               But a script trigger can be tripped by the drag and drop that results in FileMaker copying the inserted file to a specified folder and re-inserting it "by reference" using the Insert File method. This would not be used with a container field set up for External Storage.

               That leaves you with three different possible outcomes for your drag and drop. To open the file using your computer systems specified "default application" for that file type (the application that would open this file if you double clicked with your mouse outside of FileMaker), Export Field Contents can be used to export a copy of the file and open it. If you specify the temporary folder as the place to where the file is exported, this copy will not be retained when you quit FileMaker and you won't be left with a clutter of files produced by opening them in this fashion. A button can be set up to do this when clicked. This method will work with all three options.

               If you use the third option, you also can double click the container field to open the file in the computer's specified default application.

          • 2. Re: Uploading pdf, doc, avi, etc.

                 Thanks Phil,

                 I would like to then use the button set up to export field contents using a script.  
                 Set Variable [$filePath; Value: Get ( DesktopPath) ...]
                 I got this part from http://help.filemaker.com/app/answers/detail/a_id/5822/~/exporting-the-field-contents-of-a-container-field . but I am kind of confused with using the Exporting Field Content code.
                 The website says an example code is: 
            Go to Record/Request/Page [First]
                 * Set Variable [$filePath; Value: Get ( DesktopPath ) MyPics::Description & ".jpg"]
               ** Export Field Contents [MyPics::Picture; “$filePath”]  
                   Go to Record/Request/Page [Next; Exit after last]
            End Loop
                 does this export the file (.jpg in the case above) to the desktop and open it? If so, how could I incorporate this to export pdf?  Because I want to do something similar using export field contents. Rather than saving it to the desktop before opening it, I would like to specify it to a temporary folder, as you mentioned as one of the methods, and then open it.


            • 3. Re: Uploading pdf, doc, avi, etc.

                   The sample loops through a found set of records and exports one jpg file from the container field in each record. That's close to what you want but not quite. When you add Export Field contents to a script, you get a button to click to "specify out put file". That's where you type in the name of your $path variable ($filePath in the above example) and there is where you'll find a check box that you can click to specify that the file will be opened automatically after it has been exported.

                   But from your original post, you might have files of any number of types inserted into your container fields. So you'll need a different method of coming up with a file name in order to make sure that you get the correct file extension. Fortunately, the filename and extension of the inserted file can be extracted from the container field to use when assigning a file path to your $Path variable.

                   See this thread, download the exploration file from it and pay close attention to the calculation field in it that returns the file name of the file in the container field. I designed that calculation to extract the file from any container field that contains a file no matter what storage options or insertion method was  used to insert or import the file into the container field: Exploring the use of a $Path Variable in Scripts