8 Replies Latest reply on Apr 21, 2009 12:42 PM by akieru

    I need to make 3 file upload fields to fire by form button

      Hi, I have sucessfully made my form see a related thread here:

      http://forums.adobe.com/thread/419829;jsessionid=E6D4917120C2970780FAC0177938ADCD.node0?st art=15&tstart=0

       

      Thanks goes to Albert and all who helped to make it. I would like to ask for more help. I decided to make another version of the same page but to allow user to browse for image and upload it to server, then rename it to proper format store file path in database. I need to make 3 file upload fields. Each should name and store files in separate fields, but in same folder on the server.

       

      I have made a test.php page and used "multiple image upload wizard".

       

      This is my test code:

       

      //start Trigger_ImageUpload trigger
      //remove this line if you want to edit the code by hand
      function Trigger_ImageUpload(&$tNG) {
        $uploadObj = new tNG_ImageUpload($tNG);
        $uploadObj->setFormFieldName("Filedata");
        $uploadObj->setDbFieldName("firstname");
        $uploadObj->setFolder("images/");
        $uploadObj->setMaxSize(1500);
        $uploadObj->setAllowedExtensions("gif, jpg, jpe, jpeg, png");
        $uploadObj->setRename("custom");
        $uploadObj->setRenameRule("{id_location}_sample.{KT_ext}");
        return $uploadObj->Execute();
      }
      //end Trigger_ImageUpload trigger

       

      What the proper way to implement this? I think I should:

       

      1. delete the 3 text box fields I have on my form that I would like to replace with image upoad fields.

       

      2. run the "multiple image upload wizard" 3 times to make 3 separate file upload behaviors.

       

      3. remove the individual image upload buttons and make the main form submit button to work for image upload fields too.

       

       

      How do I make the main form "submit" button to work for iamge uploads and is it impotant how ADDT makes and orders Register triggers do I need to manualy edit them? My form was made by "insert into two tables wizard".

        • 1. Re: I need to make 3 file upload fields to fire by form button
          DwFAQ Level 4

          THIS TUTORIAL should give you enough to work with. Use the concept presented and tailor to fit your need. The tutorial is a little difficult to understand at times but the conceptual information provided is very useful for your situation.

           

          HERE is a demo of how to add 3 images with one submit button accomplished by following the tutorial. change no_new=3 in URL of demo page to whatever number you'd like to add more/less files.

          • 2. Re: I need to make 3 file upload fields to fire by form button
            Level 1

            The tutorial is very sketchy and hard to understand. Why it’s not converted to camtasia video is beyond me, seems very useful.

            I have page with a form created by “insert into two tables wizard”. Tried to add Developer Toolbox > Upload > upload and resize image behavior but got this error:

            “You must have form with a file input field on the page to use this behavior.”

            • 3. Re: I need to make 3 file upload fields to fire by form button
              Waleed Barakat Level 1

              Hi Folks

              I think there is another "sketchy" but useful tutorial will help you, if you don't want to use mulit upload form wizards.

               

              :: Building Instant Photo Upload Results Script :::: Building Instant Photo Upload Results Script ::
              Herein this tutorial i`ll show you how to build an instant photo upload results script, that will allow your site members to instantly view the uploaded image(s) right after the form submitted without any redirection to other pages. This option is very popular in many famous websites that running membership systems, by allowing members to upload photos and create albums etc...

               

              So you can add multiple upload fields as you wish, and after the user upload one or more than one file the instant upload results appears in the right panel, interested tutorial.

               

              But try to download the "demo" files because no upload trigger is working through the entire website.

               

              __
              Best Regards
              Waleed Barakat
              Developer-Online Creator and programmer
              www.developer-online.com

              1 person found this helpful
              • 4. Re: I need to make 3 file upload fields to fire by form button
                Level 1

                Thanks for tutorial, but this one is not for newbs too because very much information is not mentioned like enctype change and so on and I admit I'm new to this.

                 

                What I did so far:

                 

                Clicked in code view on my text box fields that I would like to convert to file upload fields.

                Changed the input type to:

                 

                type="file"

                 

                Then I tried to run developer toolbox > file uplaod > upload and resize image

                 

                But for some odd reason the wizard gave me my second table to store the image name not the first that I need. I think this is because I have customized my form to repead the second table records (add multiple second table records). So I created new page and ran insert into two tables wizard again then then  upload and resize image and I had usable code.

                 

                I pasted the code to my page, changed form enctype to: enctype="multipart/form-data"

                Then changed the $ins_paper->addColumn("sample_url", "FILE_TYPE", "FILES", "Filedata");

                I updated line: "FILE_TYPE", "FILES", "Filedata"

                for the field that I converted into file upload.

                 

                Added:

                $ins_paper->registerTrigger("AFTER", "Trigger_ImageUpload1", 97);

                 

                And my form started to work 50% the file is uploaded and written to database but no file extension is added to the filename.

                 

                This is my upload code:

                 

                //remove this line if you want to edit the code by hand
                function Trigger_ImageUpload1(&$tNG) {
                  $uploadObj = new tNG_ImageUpload($tNG);
                  $uploadObj->setFormFieldName("sample_url");
                  $uploadObj->setDbFieldName("sample_url");
                  $uploadObj->setFolder("images/");
                  $uploadObj->setMaxSize(1500);
                  $uploadObj->setAllowedExtensions("gif, jpg, jpe, jpeg, png");
                  $uploadObj->setRename("custom");
                  $uploadObj->setRenameRule("{id_paper}_sample.{KT_ext}");
                  return $uploadObj->Execute();
                }
                //end Trigger_ImageUpload1 trigger

                 

                If I change the code to $uploadObj->setRenameRule("{id_paper}_sample.jpg"); I have .jpg as file extension so why it does not work

                when I clicked on upload image behavior I got error: "the value of the selectednode property is not a node in the document" but after some clicks it opened and I so that "store filename in" :*** no column found

                 

                same code works fine on the test page that is created without "insert into two tables wizard", I don't understand where is my error.

                 

                UPDATE

                I created another test page using "insert into two tables wizard" and upload behavior still does not add file extension there too

                • 5. Re: I need to make 3 file upload fields to fire by form button
                  DwFAQ Level 4

                  "Thanks for tutorial, but this one is not for newbs too..."

                   

                   

                  You are not asking a noob question this is intermediate development. Like I said use the conceptual information to grasp the concept.  Sorry I might be speaking for myself when I say I can't hold your hand through the entire process. I read the first sentence of your last post, glanced at the remaining length of your post, and that was enough I quit reading after that. Ideally you would say you've went through the steps in the tutorial and you're having problems with step #xxx in the tutorial. You've been shown 2 separate tutorials it's up to you now to figure it out. What I mean is you've been given resources be resourceful! If you don't want to follow the tutorial and just do things on your own then go ahead and do things on your own.

                   

                  Good luck,

                  • 6. Re: I need to make 3 file upload fields to fire by form button
                    Level 1

                    The tutorial is not made to help convert or add additional fields to a form that would be used as file (image) upload fields. I do appreciate your help, but giving a tutorial that does not mention anything about actions needed to add additional fields is nonsense.

                     

                    The tutorial does not mention that I need to:

                     

                    1.Changed the input type to: type="file"

                    2. instead of

                     

                    $ins_paper->addColumn("sample_url", "STRING_TYPE", "POST", "sample_url");

                     

                    change to

                     

                    $ins_paper->addColumn("sample_url", "FILE_TYPE", "FILES", "Filedata");

                     

                    3.Ensure that new trigger is registred:

                     

                    $ins_paper->registerTrigger("AFTER", "Trigger_ImageUpload1", 97);

                     

                     

                    "Ideally you would say you've went through the steps in the tutorial and you're having problems with step #xxx in the tutorial."

                     

                    So how do I suppose to complete the tutorial and give you "step #xxx" when I can't follow it because I'm converting my form not making new one?

                     

                    "What I mean is you've been given resources be resourceful!"

                     

                    I did manage to make it this far by getting error every time I followed a step in given tutorial because information I posted above was not mentioned. So yes I was resourceful.

                     

                    If you don't want to follow the tutorial and just do things on your own then go ahead and do things on your own.

                     

                    I did ask a straight question: the file is uploaded and written to database but no file extension is added to the filename.

                     

                    I gave you my trigger code and mentioned that it does not work on another replica of the same page I created from scratch, so if you can't try to make a test form yourself with "insert into two table wizard"  and convert a text field to imageupload field to see for yourself that it does not work then don't know why you bother to respond with unhelpful post? I hope Albert will be able to help

                    • 7. Re: I need to make 3 file upload fields to fire by form button
                      DwFAQ Level 4

                      You said: "So how do I suppose to complete the tutorial and give you "step #xxx" when I can't follow it because I'm converting my form not making new one?"

                       

                      I already said: Use the concept presented and tailor to fit your need.

                       

                      Then I said:  If you don't want to follow the tutorial and just do things on your own then go ahead and do things on your own.

                       

                      You replied: "I created from scratch, so if you can't try to make a test form yourself with "insert into two table wizard"  and convert a text field to imageupload field to see for yourself that it does not work"

                       

                       

                       

                      Make a test form myself?  You must be joking right?!?  Pah-leeze

                       

                      Yes wait for someone else to help instead of helping yourself hold your breath on that one. FWIW given the resources and information provided I sincerely believe you can figure it out without being cosseted.

                       

                      The very best of luck to you,

                      • 8. Re: I need to make 3 file upload fields to fire by form button
                        Level 1

                        Problem was in step 2. Very obvious error.

                         

                        Here is the solution:

                         

                        2. instead of

                         

                        $ins_paper->addColumn("sample_url", "FILE_TYPE", "FILES", "Filedata");

                         

                        change to

                         

                        $ins_paper->addColumn("sample_url", "FILE_TYPE", "FILES", "sample_url");

                         

                        And the form will work just fine. I'm still looking for help in my other post "How to load CSV file"