5 Replies Latest reply on Jan 14, 2015 5:54 AM by erawson

    Upload Images to Another Server

    KristopherKruger

      Title

      Upload Images to Another Server

      Post

      I'm relatively new to FMP 13 - have had previous experience with a much older FMP.  

      I'm creating a database for a foundation that will receive hundreds of images.  Instead of storing those images on the FMP Server, I would like to store them on their website server which has unlimited space.  They will only refer to the images for a short period of time, but need to keep them "attached" to the record for at least five years. 

      Each record will contain about 3-5 images.  

      My question is how to create an "uploader" in FMP and "send" that file to another server - while keeping a link to that image in the record for future reference.

      Any help would be much appreciated. 

        • 1. Re: Upload Images to Another Server
          philmodjunk

          I suggest that you investigate the external storage option for a container field. This sounds like  a case where you can specify a location on the server as your external storage location. When you insert a file into the container field, FileMaker will copy the file to the external storage location and then the container field refers to the copy stored at this external storage location.

          • 2. Re: Upload Images to Another Server
            KristopherKruger

            Thank you!  I will check that out.

            • 3. Re: Upload Images to Another Server
              erawson

              I have done something very similar to what you are talking about using custom web publishing. I have a PHP script which retrieves an image from a container field in the filemaker records and writes it to the web server's file system.

              Here is a small snippet of the PHP code:

              $url = $record->getField('web__thumbnail');
              $thumbnail = $fm->getContainerDataURL($url);
              // Search for the extension of the file
              $extension = pathinfo($url, PATHINFO_EXTENSION);
              $extension = substr($extension, 0, strpos($extension, '?'));
              $file_name = pathinfo($url, PATHINFO_FILENAME);
              
              $inventoryimage->file_name = $file_name;
              
              $inventoryimage->file_extension = $extension;
              
              $inventoryimage->update();
              
              $file_contents = @file_get_contents('http://' . FM_USER . ':' . FM_PASS . '@' . $thumbnail);
              
              if($file_contents !== false) {
                  file_put_contents($inventoryimage->getDirectoryPath(), $file_contents);
              }
              • 4. Re: Upload Images to Another Server
                KristopherKruger

                Evan, thanks for the code.  I'm looking to keep the link to the image in the database and upload the image to another server.  

                I've looked at the external storage option for a container per PhilModJunk suggestion, but not sure how to reference another server - it seems it only allows me to choose a directory on the current server. 

                • 5. Re: Upload Images to Another Server
                  erawson

                  If you have ftp access to the web server you can map a drive from the filemaker server to the web server and then use that path