6 Replies Latest reply on Mar 26, 2009 4:37 PM by (Laurence_Lewis)

    Update File Upload Field

    (Laurence_Lewis)
      Hi

      I have a file upload function in a "Update Record" form. I don't need to add new entries into the DB for each upload so I set the update to entered value 1.
      However on updating the record the file uploaded to the selected folder is deleted. Is it possible to update the same table field but not have the file deleted.

      If I upload fileA and then update id field 1 to upload fileB I do not want to delete fileA when I update id 1

      I hope that makes sense

      L
        • 1. Re: Update File Upload Field
          Albert S. Level 3
          Hi Laurence,

          If I understand you correctly you can always remove the delete triggers from your form.
          • 2. Re: Update File Upload Field
            (Laurence_Lewis) Level 1
            Hi Albert

            I can't find any delete triggers in the code.

            ****CODE***
            //start Trigger_FileUpload trigger
            //remove this line if you want to edit the code by hand
            function Trigger_FileUpload(&$tNG) {
            $uploadObj = new tNG_FileUpload($tNG);
            $uploadObj->setFormFieldName("sfile_path");
            $uploadObj->setDbFieldName("sfile_path");
            $uploadObj->setFolder("../onlinemembership/supportdocs/");
            $uploadObj->setMaxSize(2000);
            $uploadObj->setAllowedExtensions("pdf, doc, txt");
            $uploadObj->setRename("auto");
            return $uploadObj->Execute();
            }
            //end Trigger_FileUpload trigger

            // Make an update transaction instance
            $upd_support_file = new tNG_update($conn_DB_ACCESS);
            $tNGs->addTransaction($upd_support_file);
            // Register triggers
            $upd_support_file->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Update1");
            $upd_support_file->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
            $upd_support_file->registerTrigger("END", "Trigger_Default_Redirect", 99, "file2-test.php");
            $upd_support_file->registerTrigger("AFTER", "Trigger_FileUpload", 97);
            // Add columns
            $upd_support_file->setTable("support_file");
            $upd_support_file->addColumn("sfile_path", "FILE_TYPE", "FILES", "sfile_path");
            $upd_support_file->setPrimaryKey("sfile_ID", "NUMERIC_TYPE", "VALUE", "1");

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

            Thanks
            L
            • 3. Re: Update File Upload Field
              Albert S. Level 3
              Hi Laurence,

              This is typically what an ADDT delete trigger looks like.

              //start Trigger_FileDelete trigger
              //remove this line if you want to edit the code by hand
              function Trigger_FileDelete(&$tNG) {
              $deleteObj = new tNG_FileDelete($tNG);
              $deleteObj->setFolder("imagefolder");
              $deleteObj->setDbFieldName("picturefield");
              return $deleteObj->Execute();
              }
              //end Trigger_FileDelete trigger

              Do you have anything like that in your page?
              • 4. Re: Update File Upload Field
                (Laurence_Lewis) Level 1
                Hi Albert<br /><br />My fathers name was Albert, used t call him Bert :-)<br /><br />No there are no delete triggers. I have decided to change the way I am setting this particular page up but have hit another snag which I think will be easier to fix.<br /><br />I have a mix of ADDT and non ADDT forms.<br /><br />The pages are a multi part form where each part of the form submits to a new pge form with the previous page form details passes as variableslike so<br /><br /><?php<br />    $gradeselection = htmlentities($_POST['gradeselection']);<br />     ?><br /><br />and passed as a hidden field<br /><br /><INPUT TYPE="hidden" name="cust_email"<br />VALUE="<?php echo $gradeselection; ?>"><br /><br />Then on the final page everything is submitted to the DB table.<br /><br />...Sorry for the long reply....<br /><br />Part of the form requires a file upload which I am using the ADDT part of the form. However the $_POST does not pass the form file field to the next page unless I append a .php?id=. The trouble with that is it stops the other frm variable being passed<br /><br />So question is how do I pass the ADDT form field variable?<br /><br />Thanks for the help, I'll also post this as a new question.<br /><br />Cheer<br />Laurence
                • 5. Re: Update File Upload Field
                  Albert S. Level 3
                  Hi Laurence,

                  Most of my friends call me Bert. I tell them you can call me Bert or you can call me Albert but just don't call me Al. :)

                  When you use ADDT's upload file it uploads the file and updates the database your saying this is killing your $variables that you are trying to maintain across the forms, correct? Without seeing any code my first thought is to convert your $variables to $_SESSION's so you can keep them moving along until the last page then destroy them after the form submits. But there maybe another way if I could see the code that has the upload file form.
                  • 6. Re: Update File Upload Field
                    (Laurence_Lewis) Level 1
                    hahaha...Especially Big Al