14 Replies Latest reply on Sep 13, 2007 3:28 AM by Günter Schenk

    How To - Validate Multiple Image Upload

    oicram Level 1
      Ok... I have a page where user can insert some informations in a database and also upload related images (without saving to the database).

      This is a free site that I'm developing for humanitary proposes, and I do want him to be good. If people responsable for submiting information of an abandonned dog do not upload an associated image, the site will have no sucess. So, its mandatory to upload some images of the dog.

      Question: How can we validate the multiple upload image SB to be "required" and IF no image is uploaded then, no Insert transaction will be made?

      Thanks
        • 1. Re: How To - Validate Multiple Image Upload
          Günter Schenk Level 4
          Hi Marcio,

          >>
          Question: How can we validate the multiple upload image SB to be "required" and IF no image is uploaded then, no Insert transaction will be made?
          >>

          well, there´s a problem with using the Multiple Image Upload *without* saving image names etc to a table :: the Insert or Update transaction that´s required to use this "multi upload" flavor, will be executed *first* and (just hope this isn´t plain wrong, but I don´t think so) has no clue of what´s exactly getting triggered afterwards

          This is a sort of "master/slave" chain of actions where the "slave" (the upload process) will just do his work after the "master" (the Insert transaction) has successfully done something else before -- but not vice versa.

          About the validation as such :: ADDT will always let you validate fields, as long they belong to a certain transaction -- but the "without save to database" image upload procedure is not part of the transaction, that´s why it´s not validatable.

          I would suggest using the "with save to database" multi-upload flavor instead. This variant will be adding an Insert transaction, and the uploaded file names will be part of this transaction and hence are supposed to be validatable. I hope :-)

          Now you might wonder why, because you assumingly don´t need all the file name info that has been stored. That´s right, but if you´d store that stuff in a "dummy" table which has no other purpose than to simply "be there", it might make some sense -- noone will ever force you to query that dummy table, so what ? :-)

          That´s actually all just some "food for thought" for you, as I never tried that myself -- but from knowing ADDT´s "logic", I´m somewhat certain it will work out after all.

          Cheers,
          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: How To - Validate Multiple Image Upload
            oicram Level 1
            saving images in the database: I would prefer that solution to, from the beginning of my project.

            But without doing it I have learn that he works in fact not badly.

            1)
            He creates a temp folder with the same name as the record ID and, IF the record is not inserted, it stays like a temp folder and will delete isself after same time.

            2)
            With the filelist recorset I'm able to show the images associated with a specific record.
            (so with the Save to Database SB obviously)

            3)
            I'm able to delete only specific images "associated" with the record.
            (so with the Save to Database SB obviously to)

            4)
            And it happens also , when I delete the record, the images are flushed to.
            (same with the Save to Database SB)

            But I miss the validation.

            Saving image to the database creates a upload button in my page where I can send several images and associated informations.

            But the scenario here is a little bit diferent:

            I have a form (already created) that the user should fill the information and also add associated images. In this case, fill the dog informations and click upload button to upload several images of that dog.

            Can this be donne using the save to database wizard?

            Thanks Günter.
            • 3. Re: How To - Validate Multiple Image Upload
              Günter Schenk Level 4
              Hi Marcio,

              I have to admit that I didn´t use the "multiple image upload with save to DB" feature so far and hence can´t say anything about the validation -- that said, I will leave it all up to to try ;-)

              >>
              1)
              He creates a temp folder with the same name as the record ID and, IF the record is not inserted, it stays like a temp folder and will delete isself after same time
              >>

              that certainly can´t be done without lots of manual coding.

              However, I´d suggest deciding on a far less complicated strategy in your case:

              1. for the *initial* info related to dog X :: create an "insert record form" containing the required fields for adding the basic info, plus add a *single* image upload field -- single file fields can always be validated for missing content, as they are clearly part of the transaction.

              2. for all additional pics related to the previously inserted dog X :: create an "update record transaction" which will enter some predefined bogus data in a "dummy" table (what´s mentioned in another thread here -- happy searching :-)), and attach the "multi image upload without saving to database" to this transaction -- you´ll just need to provide a query (based on certain information stored in the inserted record, like e.g. dog_id) which will make sure that the additional pics will be uploaded in the correct image folder related to dog X.

              The reasons for suggesting this approach is :: step 2) will not interfer with what´s already been done in step 1), and just case the user doesn´t actually upload any pics in step 2), it won´t have any negative effect at all, because having updated some bogus data in a separate "dummy" table won´t affect your relevant data at all

              Cheers,
              Günter Schenk
              Adobe Community Expert, Dreamweaver
              • 4. Re: How To - Validate Multiple Image Upload
                oicram Level 1
                I'm trying to understand your approach...

                Do you mean:

                1)
                In the backend:
                The user will add the information of a dog, and also ONE image associated.

                He/She click insert.

                After this, he/she goes to the same record and updates with the new pictures?

                OR, do you mean:

                2) Before click insert they will have the ordinary informations to fill out, then 2 buttons. One that says "Add Image" (can be validated) and another that says "Add more images" (that cannot be validated).

                If the user decides not to click in "Add more images" at least one image is uploaded and ready to be show in the frontend.

                with one is the solution you propose?


                Thanks again and again... :)
                • 5. Re: How To - Validate Multiple Image Upload
                  Günter Schenk Level 4
                  Hi Marcio,

                  >>
                  with one is the solution you propose?
                  >>

                  it´s 1)

                  make the "update form" update e.g a column "dummy_text" in a totally different "dummy" table (e.g. WHERE dummy_id = 1) -- but make the multi image upload shove all pics into the correct folder, which can be determined from the record´s "dog_id" or whatever you´re passing to this form as URL variable.

                  that should work IMHO, but once again -- that´s something new I didn´t even try myself

                  Günter Schenk
                  Adobe Community Expert, Dreamweaver
                  • 6. Re: How To - Validate Multiple Image Upload
                    oicram Level 1
                    Hmm... but that implies for each dog, 2 inserts. One for same text and 1 picture. Submit Ok. --> sucesspage.php then, return to the record, and update (dummy update) but with more images to upload as option (based on dog_id).

                    The problem is, if it is like i'm descriving, that is not pratical for the user: "Do an insert than return to the record page to do an "update" for other images..."

                    I will think a little bit more in this side, and then I will post back other possible workaround, if I cannot find another way, I will leave the multiple image upload without validation and search a really funny imagenotfound.jpg to put on the side when some dog responsable don't upload dog pictures.

                    If I get other ideas I will post here, please stay tunned to help me out... please. :D

                    Thanks
                    • 7. Re: How To - Validate Multiple Image Upload
                      Günter Schenk Level 4
                      Hi Marcio,

                      basically you could as well provide a sort of personalized ADDT "dynamic list", means, a List which will be managing the records from your "dogs" table WHERE owner_id matches the standard "kt_login_id" session variable

                      There´s actually something about the ADDT Dynamic Lists which folks are not usually aware of:

                      1. the List´s associated "update" forms don´t have to be "multiple records" forms like the ones created with ADDT´s "Create Dynamic Form Wizard" -- they can as well be simple regular update forms.

                      2. the List´s "insert new" link can be defined to rather point to a specific page that´s providing a simple "Insert Record" form.

                      However, as you can always have your "insert" and "update" form redirect to this "Dynamic List", the whole thing will become notably more manageable to the user -- and once he/she did insert a record, it will be displayed right away in the List, means, he can easily update the desired record from here.

                      Günter Schenk
                      Adobe Community Expert, Dreamweaver
                      • 8. Re: How To - Validate Multiple Image Upload
                        oicram Level 1
                        What about this: :D

                        Search if directory in the webserver with the same name of the record ID are not empty.
                        If are not empy: go to sucesspage.php
                        If empy return to the samepage and "print" you cannot insert a record without associated images.

                        The ADDT script "interakts" :) with the server somehow to put create the folders... if he can do this, he can also verifies...

                        The question is... Günter... HOW?! :D :D

                        :D

                        :D
                        • 9. Re: How To - Validate Multiple Image Upload
                          Günter Schenk Level 4
                          Hi Marcio,

                          >>
                          The ADDT script "interakts" with the server somehow to put create the folders... if he can do this, he can also verifies...
                          >>

                          not at all ! ADDT has no built-in features which will check and return how many files have been uploaded to a directory it created.

                          Günter Schenk
                          Adobe Community Expert, Dreamweaver
                          • 10. Re: How To - Validate Multiple Image Upload
                            oicram Level 1
                            First problem, the directory with the ID only appears on the server IF the record is inserted. But I cannot Insert the record twice so I will have an error... I will think a litlle bit more and post back...

                            sorry for the last post.
                            • 11. Re: How To - Validate Multiple Image Upload
                              oicram Level 1
                              The problem with the list solution is that the form is a multi-step one. Because its a lot of data that need to be filled in. So I have divided the form to be filled in, in tabs. (Spry)

                              I will keep searching... anyway this is not the only thing that I have the think about so, I will do other project stuffs.

                              Thanks for you help. (i'm not closing this, just leaving for later on).

                              tschuss.
                              • 12. Re: How To - Validate Multiple Image Upload
                                Günter Schenk Level 4
                                Hi Marcio,

                                >>
                                sorry for the last post
                                >>

                                no need to say sorry -- to me it´s very interesting to see how you´re trying to find some quite exceptional and "cool" ways to get what you need !

                                And as you´re certainly be sharing your freaky ((;-)) solution sooner or later in these forums for others to see, it will be exactly your special approach which might be helpful to others in some ways !

                                Cheers,
                                Günter Schenk,
                                Adobe Community Expert, Dreamweaver
                                • 13. Re: How To - Validate Multiple Image Upload
                                  oicram Level 1
                                  Lol, ok. I will back soon with more Freaky solutions. :)
                                  • 14. Re: How To - Validate Multiple Image Upload
                                    Günter Schenk Level 4
                                    >>
                                    I will back soon with more Freaky solutions
                                    >>

                                    oh NOOOOOOOOOOOO ! :-)

                                    Günter Schenk,
                                    Adobe Community Expert, Dreamweaver