1 2 Previous Next 26 Replies Latest reply on Feb 16, 2012 4:43 PM by philmodjunk

    upload images on batch

    Fagreement

      Title

      upload images on batch

      Post

      How can I upload images on batch (select all images in a folder) and create a record on a table for each of these images.

      Possible?

      i used import record but doesn't work

        • 1. Re: upload images on batch
          philmodjunk

          Import records with the folder option should do exactly what you describe: Import all the image files creating a new record for each.

          • 2. Re: upload images on batch
            Fagreement

            yes it works as folder. thanks

            but how can i let the user to choose - within a folder - only the photos that he want to import?

            • 3. Re: upload images on batch
              Fagreement

              anathor 2 questions:

               

              1. how can i fix the fields maping when the user wan tto import records. what i mean, i don't want the user choose the fields maping, theyr are fixed and i want to define this maping one for all.

              2. it seems that when i import records the triggers are not triggered. in fact, I'm importing images in a container, so in the field maping i choose the appropriate field and it works. but the pbm is that i want also to map the photo that i'm importing to another field in another table. i thought i can use the trigger on object change but it doesn't work!

               

              thanks

              • 4. Re: upload images on batch
                Fagreement

                ok for the point 1, i found it :)

                remain the number 2

                • 5. Re: upload images on batch
                  philmodjunk

                  but how can i let the user to choose - within a folder - only the photos that he want to import?

                  Using only built in FileMaker capabilities, you have two choices: import all the photos and discard the unwanted copies after import or import the photos one at a time. Might be simpler to move the selected photos into a separate folder for import purposes. Even if you import references that need to refer to their original location, this can still be done if you update the file refrences in the container field after the fact.

                  Other options would be to use either a system script--such as applescript or a batch file--or a plug in to list the folder file names in a field or portal on a layout, Then the user can select the desired files and run a script that loops through such a list to insert the photos one file at a time.

                  2. it seems that when i import records the triggers are not triggered. in fact, I'm importing images in a container, so in the field maping i choose the appropriate field and it works. but the pbm is that i want also to map the photo that i'm importing to another field in another table. i thought i can use the trigger on object change but it doesn't work!

                  Correct.  script triggers will not be tripped by import records. Import records does not interact with your layouts and thus cannot trip script triggers. I am puzzled as why you would want to copy the contents of a container field to a different table here--duplicating the data. Establishing a relationship that links to the record with the imported image would seem a better idea. Importing Records creates a found set of the newly created records. Thus, you can use a script to loop through them to further process the data after import. Thus, you may be able to set up a looping script that will do what you need here.

                  • 6. Re: upload images on batch
                    Fagreement

                    2. ok i see.

                    But how, via a script, in an intelligence way, can I loop on all the new record newly imported and set the desired container to the new value?

                     

                    EX;

                    1. i'm using the following statement to import photos

                    2. in the mappig field i'm copying the filepath of the photo into Photo::Filepath

                    3. in a script i want to map "as reference" the photo in another table, linked to photo table, PhotoTableInFM::PhotoContainerInFM. this field i'm using it to display on the layout the photo to the user.

                    Note that i'm using SQL as DB.

                     

                    THANK YOU

                    • 7. Re: upload images on batch
                      philmodjunk

                      I don't know enough about your tables to tell you.

                      I'm also not sure that I understand exactly what you want to do here. I think you have records created by the Import, each with a photo that you want to link to a record or records in a related table. Or do you need to copy the imported photo into a container field in that other table?

                      How do you know which record in the other table is the one to which you want to link a record created by your import? (What does your script trigger script do?)

                      • 8. Re: upload images on batch
                        Fagreement

                        here is my relationship Photo (table created in SQL) and PhotoTableInFM (in FM)

                        (PhotoID=PhotoTableIDInFm)

                        so my import are in Photo Table n the mappig field i'm copying the filepath of the photo into Photo::Filepath

                        so in "normal" mode, the user insert, by ref, a photo in PhotoTableInFM::PhotoContainerInFM and the filepath is stoked in photo:Filepath

                        now the scenraio is another way: when i import, photo:Filepath is filled, but not PhotoTableInFM::PhotoContainerInFM

                        • 9. Re: upload images on batch
                          philmodjunk

                          Your relationship:

                          Photo::PhotoID = PhotoTableInFM::PhotoTableIDInFm

                          Does this mean that for every record created in Photo by the import, you need to create a matching new record in PhotoTableInFM?

                          Otherwise, I don't see how to determine which record in PhotoTableInFm will match to a newly imported record in Photo.

                          How do PhotoID and PhotoTableIDInFm get their values?

                          • 10. Re: upload images on batch
                            Fagreement

                            Does this mean that for every record created in Photo by the import, you need to create a matching new record in PhotoTableInFM?

                            >>yes

                             

                            How do PhotoID and PhotoTableIDInFm get their values?

                            >>PhotoID: incremental, created in FM by the user when a record ic reated in Photo. then if the user edit the image in table photo, automatically a record will be created in PhotoTableInFM, and the field PhotoTableIDInFm is incremental.

                            • 11. Re: upload images on batch
                              philmodjunk

                              Make sure that PhotoID gets a value during import. Otherwise you will need to assign values to this field before doing the following:

                              If "allow creation" is enabled for PhotoTableInFm in this relationship, Set Field [PhotoTableInFM::PhotoContainerInFM ; Photo::containerField]

                              Will create the new record put the reference from container field into PhotoContainerInFM and copy PhotoID into PhotoTableIDInFm.

                              Thus you can use

                              Go to record/requst/page [first]
                              Loop
                                 Set Field [PhotoTableInFM::PhotoContainerInFM ; Photo::containerField]
                                 Go to record/requst/page [next ; exit after last]
                              End Loop

                              I'd have to try it manually once to be sure but a single Replace Fields step would likely do this without needing to script a loop.

                              If Allow create is not enabled, you'll need to copy values into variables and change layouts back and forth to create new records on the PhotoTableInFM and assign values from the variables to it to set it up, the switch back to the original layout for the next iteration of the loop.

                              • 12. Re: upload images on batch
                                Fagreement

                                thank you very much

                                • 13. Re: upload images on batch
                                  Fagreement

                                  it seems the loop  is passing only for the first record, and not looping to all records!

                                  this is my script:

                                  • 14. Re: upload images on batch
                                    philmodjunk

                                    Assuming that you are importing into the Photo table, you would run this script from a layout to the Photo table immediately after the Import Records process so that it can step through the records created by the import.

                                    1 2 Previous Next