12 Replies Latest reply on Nov 22, 2011 12:18 PM by Lizhe

    How to make client save an attachment file to the Server (Central) location

    Lizhe

      Our team members have to attach data files (.jpg, pdf, xlsx, or docx) to the FM solution from the client computers. We'd like to keep them in central place at server side but outside the database itself, so members can share the data from different places. Recently we purchased Trio File plug-in but not the SuperContainer due to our tight budget (I guess it may be easier with SuperContainer). I'd like to learn how to build up the function with what we have now, to save the file and retrieve the file from Client computer. Thank you very much.

        • 1. Re: How to make client save an attachment file to the Server (Central) location

          Hi Ryan,

           

          I would not be without SuperContainer and especially if there is any risk of you shuffling the location of your stored files from one place to another during development.

           

          The storage of fabric images for our website, for the various layouts where they are displayed locally, and for the databases written for use on iPod and iPad, SuperContainer has worked so well that I cannot see us ever reverting to storing them by file reference.

           

          I'm sure that your saving in development (and potentially redeployment) time would soon give you the necessary ROI to justify its purchase.

           

          Cheers,

           

          John

          Hamilton, NZ

          • 2. Re: How to make client save an attachment file to the Server (Central) location
            RayCologon

            Hi Ryan,

             

            As long as two conditions are met:

             

            1. The path to the server directory is the same from all client workstations, and

            2. You can be assured that the shared server directory will be mounted and available on client computers at all times

             

            ...then you don't really need either plug-in to make this work. That is, FileMaker will respect the file paths to the remote directory when files stored on the shared volume are inserted using the "Store only a reference to the file" attribute.

             

            Regards,

            Ray

            ------------------------------------------------

            R J Cologon, Ph.D.

            FileMaker Certified Developer

            Author, FileMaker Pro 10 Bible

            NightWing Enterprises, Melbourne, Australia

            http://www.nightwingenterprises.com

            ------------------------------------------------

            1 of 1 people found this helpful
            • 3. Re: How to make client save an attachment file to the Server (Central) location
              Lizhe

              Hi John,

              I do want to get the SuperContainer. However, as a federal gov agency we have a budget cut close to 50%. In addition, FM is not on our agency C&A (certification and accreditation) program list. You don't know how hard to keep our intranet FM server running. It makes even harder to justify a purchase on an expensive plug-in :-(.

              • 4. Re: How to make client save an attachment file to the Server (Central) location
                rbarlow03

                We do exactly what Ray describes.  All users have an AD pushdown for the share which solves any issue about the shared directory not being mounted.

                • 5. Re: How to make client save an attachment file to the Server (Central) location
                  Lizhe

                  Wonderful, I'll do a serach online on the "Store only a reference to the file" attribute. If you have some example codes to show me, it would be extremely helpful. Thank you so much.

                  • 6. Re: How to make client save an attachment file to the Server (Central) location
                    RayCologon

                    RyanTX wrote:

                    Wonderful, I'll do a serach online on the "Store only a reference to the file" attribute. If you have some example codes to show me, it would be extremely helpful. Thank you so much.

                     

                    Hi Ryan,

                     

                    When you insert a file (or image etc) into a container field manually, the dialog that allows you to select the file has a checkbox at the bottom enabling you to choose whether the file will be loaded into the field or whether just its path will be stored (allowing FileMaker to access it from a mounted volume - including a central serve, as I mentioned earlier). Here's what the option looks like on a Mac:

                     

                    StoreAsReference.png

                    If you script the process, you can choose the option while setting up the script and it will be applied by default whenever users select a file to insert.

                     

                    It's basically the same routine if you are importing a folder of images or movies etc - the relevant Options dialog also has a checkbox for "Import only a reference":

                     

                    FolderImport.png

                    ...and again, this is scriptable.

                     

                    With a bit of experimentation using the above pointers, you should find that it's reasonably straightforward.

                     

                    Regards,

                    Ray

                    ------------------------------------------------

                    R J Cologon, Ph.D.

                    FileMaker Certified Developer

                    Author, FileMaker Pro 10 Bible

                    NightWing Enterprises, Melbourne, Australia

                    http://www.nightwingenterprises.com

                    ------------------------------------------------

                    1 of 1 people found this helpful
                    • 7. Re: How to make client save an attachment file to the Server (Central) location
                      Lizhe

                      Hi Ray,

                       

                      Thank you very much for your detailed instruction. I did get the "store only a reference..." working in a script when user attach his file from client computer. But how to copy the file from client side to the shared HD in FileMaker without plug-ins?

                      Thanks.

                       

                       

                       

                      R

                      • 8. Re: How to make client save an attachment file to the Server (Central) location
                        RayCologon

                        RyanTX wrote:

                        But how to copy the file from client side to the shared HD in FileMaker without plug-ins?

                        Thanks.

                         

                        Hi Ryan,

                         

                        The method will be a little different depending on whether the file has been uploaded or stored as a reference.

                         

                        If it was stored as a reference (eg by your script), you should use a global container field (eg in a utility table) and insert the file from its local path (you can retrieve the path by enclosing the container field where the file was uploaded in the GetAsText() function - the path to the file is included in the text returned). So, load the path as a variable and pass the variable to the relevant Insert command (Insert File[ ], Insert Picture[ ] etc). This time don't choose the "Store as reference" option. Then immediately use Export Field Contents[ ] to place the contents of the global utility (container) field into the directory on the shared HD, and delete the temporary file from the global utility container. Finally, update the original container field with the new path (so it is pointing to the shared HD copy of the file, not the local one). Done.

                         

                        If you also want to delete the local copy of the file as part of this exercise, you can do so after the above procedure by re-using the variable that represents the path to the local file and calling an Export Field Contents[ ] command specifying the local path as the destination but leaving the target field attribute null.

                         

                        If the file was originally loaded into the field rather than being stored as a reference, you can do much the same, except you won't need the global container field in the utility table, you can work directly with the original container - and, of course, you don't need the first step (of uploading the local file) - you can use Export Field Contents[ ] straight off.

                         

                        By extension, using variations on these native FileMaker techniques, you can manage external files - both local and remote, creating, moving, renaming and deleting files - in other words, rudimentary file management. If you want frills you may need a plug-in (or external script calls etc), but not for the basics.

                         

                        Regards,

                        Ray

                        ------------------------------------------------

                        R J Cologon, Ph.D.

                        FileMaker Certified Developer

                        Author, FileMaker Pro 10 Bible

                        NightWing Enterprises, Melbourne, Australia

                        http://www.nightwingenterprises.com

                        ------------------------------------------------

                        • 10. Re: How to make client save an attachment file to the Server (Central) location
                          Lizhe

                          I tested on the attachment saved as a file on Server. It works great and new file was created in a central location. However, when I tested on the attachment saved as a reference. I got an error of 102 (missing field) on the step to insert the file to the global container. I checked my script, but could not figure out what's wrong. Please help. Attached is the debug of the script.

                          Field:     result is a local container field

                                       result_global is a global container field.

                          variable  $path contains the absolute path to the file

                           

                          Thanks.

                          Error102.jpg

                           

                          Fields.jpg

                          • 11. Re: How to make client save an attachment file to the Server (Central) location
                            RayCologon

                            RyanTX wrote:

                             

                            I tested on the attachment saved as a file on Server. It works great and new file was created in a central location. However, when I tested on the attachment saved as a reference. I got an error of 102 (missing field) on the step to insert the file to the global container...

                             

                            Hi Ryan,

                             

                            All of FileMaker's Insert... commands require that the targeted field be present on the current layout when they are called, otherwise they will fail (returning a 102 error because the field was not found).

                             

                            The most likely problem, I am guessing, is that your script is not on a layout where the EXP::Result_global field is available, when it gets to the Insert File[ ] step.

                             

                            Regards,

                            Ray

                            ------------------------------------------------

                            R J Cologon, Ph.D.

                            FileMaker Certified Developer

                            Author, FileMaker Pro 10 Bible

                            NightWing Enterprises, Melbourne, Australia

                            Email: cologon@nightwingenterprises.com

                            http://www.nightwingenterprises.com

                            ------------------------------------------------

                            • 12. Re: How to make client save an attachment file to the Server (Central) location
                              Lizhe

                              You are absolutely right. Thank you so much.