15 Replies Latest reply on Jun 11, 2008 10:13 PM by Günter Schenk

    How to make the upload folder dynamic in  Multiple Image Upload Behavior

    Level 1
      When I change the folder name in the multiple upload image behavior wizard to a new name that is not already on the server it does create the new folder and does insert the image OK.
      How do I now make the upload folder dynamic in the multiple upload image behavior so that I can insert the new folder name in a form on the same page before selecting the images to upload? I tried the form var but it ignored that approach.
        • 1. Re: How to make the upload folder dynamic in  Multiple Image Upload Behavior
          How did you enter the variable value, and is the value available when you open the form?

          I have used...

          {GET.adid}/{uac_UserAdContentID}

          ...to specify the dynamic folders, and so long as these values are available when uploading the files it will work. IOW I can't use {uac_UserAdContentID} when inserting a new record into UserAdContent because at that time the value of {uac_UserAdContentID} has not been set, because the record created by the form has not been created.
          • 2. Re: How to make the upload folder dynamic in  Multiple Image Upload Behavior
            Level 1
            Can the name of the image file be different on the server, changed during the upload?
            • 3. Re: How to make the upload folder dynamic in  Multiple Image Upload Behavior
              Günter Schenk Level 4
              Hi Dave,

              -----
              Can the name of the image file be different on the server, changed during the upload?
              -----

              that´s what you can control (to some extent) using the "renaming rules"

              Cheers,
              Günter Schenk
              Adobe Community Expert, Dreamweaver
              • 4. Re: How to make the upload folder dynamic in  Multiple Image Upload Behavior
                Level 1
                Thanks Günter,
                I am not sure that would work for me. I want to use a session var to determine the name of the graphic file. I gave up on the dynamic folder for now.

                I have another question about your tutorial on use of the dummy table to upload a grqaphic file. I have got it to work and also had success with the multiple upload but ran into this error while following your tutorial again today.

                File upload error. Field "dummytext" does not have the "Submit as" property set to "file". (FILE_UPLOAD_WRONG_COLTYPE)
                • 5. Re: How to make the upload folder dynamic in  Multiple Image Upload Behavior
                  Level 1
                  Hi again Günter,
                  I also wonder about the fact that when you comment out //$uploadObj->setDbFieldName("dummytext"); the Upload Image(dummytext) disapears from the Appplication->Server Behaviors panel.
                  Does that present any problem?
                  • 6. Re: How to make the upload folder dynamic in  Multiple Image Upload Behavior
                    Günter Schenk Level 4
                    Hi Dave,

                    commenting that line out will not generate an error under "live conditions", means when the page is loaded in the browser -- but if you plan the to launch the Server Behaviour UI in DW again for making some changes here, you´d better delete those comments temporarily, as it might well be that the UI will stumble across this unexpected modification

                    Cheers,
                    Günter Schenk
                    Adobe Community Expert, Dreamweaver
                    • 7. Re: How to make the upload folder dynamic in  Multiple Image Upload Behavior
                      Level 1
                      Thanks Günter,
                      I gave up on the dynamic folder for now.
                      I think you missed my most important question:

                      I have another question about your tutorial on use of the dummy table to upload a grqaphic file. I have got it to work and also had success with the multiple upload but ran into this error while following your tutorial again today.

                      File upload error. Field "dummytext" does not have the "Submit as" property set to "file". (FILE_UPLOAD_WRONG_COLTYPE)
                      • 8. Re: How to make the upload folder dynamic in  Multiple Image Upload Behavior
                        Günter Schenk Level 4
                        Hi Dave,

                        I didn´t "miss" your most important question, I simply had no time to make up my mind on this until now.

                        Don´t know why this happens, but are you using this trick with the multiple upload then ? If so, I´d have to have a closer look at that, because my tutorial deals with single upload

                        Cheers,
                        Günter Schenk
                        Adobe Community Expert, Dreamweaver
                        • 9. Re: How to make the upload folder dynamic in  Multiple Image Upload Behavior
                          Level 1
                          Hi Günter,<br />I have no problem with the multiple uploads. I do not know what you mean "but are you using this trick with the multiple upload then"<br />I am concerned about the error:<br />File upload error. Field "dummytext" does not have the "Submit as" property set to "file". (FILE_UPLOAD_WRONG_COLTYPE) <br />when trying the single upload as per the tutorial.<br />I watched the Image Upload & Display video from MX Kollection :: Documentation with the same outcome. Here is the code from my most current try, this time I was using an insert instead of update, but I got the same results (hope that is not a problem):<br /><?php require_once('../Connections/domainname.php'); ?><br /><?php<br />// Load the common classes<br />require_once('../includes/common/KT_common.php');<br /><br />// Load the tNG classes<br />require_once('../includes/tng/tNG.inc.php');<br /><br />// Make a transaction dispatcher instance<br />$tNGs = new tNG_dispatcher("../");<br /><br />// Make unified connection variable<br />$conn_dsbycnet = new KT_connection($dsbycnet, $database_dsbycnet);<br /><br />//start Trigger_ImageUpload trigger<br />//remove this line if you want to edit the code by hand <br />function Trigger_ImageUpload(&$tNG) {<br />  $uploadObj = new tNG_ImageUpload($tNG);<br />  $uploadObj->setFormFieldName("filename");<br />  $uploadObj->setDbFieldName("dummytext");<br />  $uploadObj->setFolder("../memberPict/images/");<br />  $uploadObj->setResize("true", 100, 100);<br />  $uploadObj->setMaxSize(10000);<br />  $uploadObj->setAllowedExtensions("gif, jpg");<br />  $uploadObj->setRename("auto");<br />  return $uploadObj->Execute();<br />}<br />//end Trigger_ImageUpload trigger<br /><br />// Make an insert transaction instance<br />$ins_dummy = new tNG_insert($conn_domainname);<br />$tNGs->addTransaction($ins_dummy);<br />// Register triggers<br />$ins_dummy->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");<br />$ins_dummy->registerTrigger("END", "Trigger_Default_Redirect", 99, "thanks.php");<br />$ins_dummy->registerTrigger("AFTER", "Trigger_ImageUpload", 97);<br />// Add columns<br />$ins_dummy->setTable("dummy");<br />$ins_dummy->addColumn("dummytext", "STRING_TYPE", "VALUE", "bla bla");<br />$ins_dummy->setPrimaryKey("id", "NUMERIC_TYPE");<br /><br />// Execute all the registered transactions<br />$tNGs->executeTransactions();<br /><br />// Get the transaction recordset<br />$rsdummy = $tNGs->getRecordset("dummy");<br />$row_rsdummy = mysql_fetch_assoc($rsdummy);<br />$totalRows_rsdummy = mysql_num_rows($rsdummy);<br />?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /><html xmlns="http://www.w3.org/1999/xhtml"><br /><head><br /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br /><title>Untitled Document</title><br /><link href="../includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" /><br /><script src="../includes/common/js/base.js" type="text/javascript"></script><br /><script src="../includes/common/js/utility.js" type="text/javascript"></script><br /><script src="../includes/skins/style.js" type="text/javascript"></script><br /></head><br /><br /><body><br /><p><br />  <?php<br />     echo $tNGs->getErrorMsg();<br />?><br /></p><br /><table width="100" border="1"><br /><form id="form1" name="form1" enctype="multipart/form-data" method="post" action=""><br />  <tr><br />    <td><br />        <input type="file" name="filename" id="filename" /><br />    </td><br />  </tr><br />  <tr><br />    <td><br />        <input type="submit" name="KT_Insert1" id="KT_Insert1" value="Upload" /><br />    </td><br />  </tr><br /></form><br /></table><br /><p> </p><br /></body><br /></html>
                          • 10. Re: How to make the upload folder dynamic in  Multiple Image Upload Behavior
                            Günter Schenk Level 4
                            Hi Dave,

                            my working (!) code is actually identical to what you posted -- with one exception :: I´m using an update transaction (which will update the existing ID 1), just because it doesn´t make any sense to add new "bla bla" records to the "dummy" table:

                            -------
                            //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("filename");
                            //$uploadObj->setDbFieldName("dummytext");
                            $uploadObj->setFolder("../../tutorials/assets/");
                            $uploadObj->setMaxSize(800);
                            $uploadObj->setAllowedExtensions("jpg, jpeg");
                            $uploadObj->setRename("auto");
                            return $uploadObj->Execute();
                            }
                            //end Trigger_ImageUpload trigger

                            // Make an update transaction instance
                            $ins_dummy = new tNG_update($conn_conn);
                            $tNGs->addTransaction($upd_dummy);
                            // Register triggers
                            $ins_dummy->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Update1");
                            $upd_dummy->registerTrigger("END", "Trigger_Default_Redirect", 99, "list.php");
                            $upd_dummy->registerTrigger("AFTER", "Trigger_ImageUpload", 97);
                            // Add columns
                            $upd_dummy->setTable("dummy");
                            $upd_dummy->addColumn("dummytext", "STRING_TYPE", "VALUE", "blablabla");
                            $upd_dummy->setPrimaryKey("id", "NUMERIC_TYPE", "VALUE", "1");

                            // Execute all the registered transactions
                            $tNGs->executeTransactions();

                            // Get the transaction recordset
                            $rsdummy = $tNGs->getRecordset("dummy");
                            $row_rsdummy = mysql_fetch_assoc($rsdummy);
                            $totalRows_rsdummy = mysql_num_rows($rsdummy);
                            -------

                            Other than that it´s identical, but you can see that I *do* comment that particular line out, and most assumingly this will make a difference, because your posted code has this line still intact.

                            BTW, you might have noticed that this forum renders posted HTML code into sheer mess -- please rather post a link to a .txt file on your server in such cases.

                            Cheers,
                            Günter Schenk
                            Adobe Community Expert, Dreamweaver
                            • 11. Re: How to make the upload folder dynamic in  Multiple Image Upload Behavior
                              Level 1
                              Hi Günter,
                              U said >> but you can see that I *do* comment that particular line out
                              You were right, duh!
                              I commented the line out and it worked.
                              Thanks again...

                              Now I have a new problem.....
                              I am adding the Trigger_Delete_Exsisting behavior to the upload.php which uses the dummy database.
                              no mater what I call the File Field, I get this error

                              tNG_fields.getColumnValue:
                              Column myimage is not part of the current transaction.

                              http://rmace.com/upload_php_error.txt
                              • 12. Re: How to make the upload folder dynamic in  Multiple Image Upload Behavior
                                Günter Schenk Level 4
                                Hi Dave,

                                wow, you´re apparently the first one who´s mixing stuff from two separate tutorials :-)

                                ----
                                Column myimage is not part of the current transaction
                                ----

                                that´s because you´re currently using a static "bla bla" text here, which has no relation to the $tNG->getColumnValue you´re requesting -- that´s why ADDT considers it non existant, what it currently is:

                                $upd_dummy->addColumn("dummytext", "STRING_TYPE", "VALUE", "bla bla");

                                Please try replacing it with:

                                $upd_dummy->addColumn("dummytext", "STRING_TYPE", "POST", "myimage");

                                ..what should work, as the update trigger now has a reference to the file field.

                                Cheers,
                                Günter Schenk
                                Adobe Community Expert, Dreamweaver
                                • 13. Re: How to make the upload folder dynamic in  Multiple Image Upload Behavior
                                  Level 1
                                  Hi Günter,
                                  Thanks for your help.
                                  I made the changes. Still getting this error.

                                  tNG_fields.getColumnValue:
                                  Column image is not part of the current transaction.

                                  Maybe I need to keep the file name in my database if that is where it is looking for the file name. I have a DB associated with this and there is a record for each picture.

                                  I updated the text file so you can see what I have
                                  http://rmace.com/upload_php_error.txt
                                  • 14. Re: How to make the upload folder dynamic in  Multiple Image Upload Behavior
                                    Level 1
                                    Hi Günter,
                                    Will your overwrite exsisting file or image trigger work with the multiple upload behaviour?
                                    • 15. Re: How to make the upload folder dynamic in  Multiple Image Upload Behavior
                                      Günter Schenk Level 4
                                      Hi Dave,

                                      -------
                                      Will your overwrite exsisting file or image trigger work with the multiple upload behaviour?
                                      -------

                                      I don´t know, because I didn´t try it in this context.

                                      Cheers,
                                      Günter Schenk
                                      Adobe Community Expert, Dreamweaver