7 Replies Latest reply on Jul 20, 2007 3:29 AM by (Ruben_Maestre)

    File upload custom renaming not working with {KT_ext}

      Hi,

      I used many times custom renaming with file upload, and used {KT_ext} for file's extension, but in first ADDT project is not working. I use this:

      $uploadObj->setRenameRule("{GET.id_cd}_{track}.{KT_ext}");

      Does anybody know if {KT_ext} is broken in ADDT?

      Thank you,
      Ruben
        • 1. Re: File upload custom renaming not working with {KT_ext}
          Günter Schenk Level 4
          Hi,

          as far as I can see after checking ADDT´s libraries, "KT_ext" is still in there -- what happens, the file extension is getting ignored then ?

          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: File upload custom renaming not working with {KT_ext}
            Level 1
            Hi Günter,

            yes, it's ignored. The {GET.id_cd} gets URL parameter, {track} is from transaction recordset (in Update Transaction), but {KT_ext} is ignored. So the file created is named like "1_1.". In this case I can force "mp3" to be used as extension, as the form only works with this one, using

            $uploadObj->setRenameRule("{GET.id_cd}_{track}.mp3");

            but I need another file upload with pdf and doc extensions, and I'm afraid I'll have problems.

            Thank you for your help,
            Ruben
            • 3. Re: File upload custom renaming not working with {KT_ext}
              Günter Schenk Level 4
              Hi Ruben,

              I just tried to reproduce your problem by implementing an ADDT file upload and using the "KT_ext" as file suffix -- works absolutely fine for me !

              Can you please post the complete

              function Trigger_FileUpload(&$tNG) {
              ...
              }

              here ? Maybe this issue is related to something else in here, but all I can say is, "KT_ext" is not broken

              Günter Schenk
              Adobe Community Expert, Dreamweaver
              • 4. Re: File upload custom renaming not working with {KT_ext}
                Level 1
                Hi Günter,

                I know it's a bit estrange... This is the complete function:

                function Trigger_FileUpload(&$tNG) {
                $uploadObj = new tNG_FileUpload($tNG);
                $uploadObj->setFormFieldName("mp3");
                $uploadObj->setDbFieldName("mp3");
                $uploadObj->setFolder("../mp3/");
                $uploadObj->setMaxSize(5000);
                $uploadObj->setAllowedExtensions("mp3");
                $uploadObj->setRename("custom");
                $uploadObj->setRenameRule("{GET.id_cd}_{track}.{KT_ext}");
                return $uploadObj->Execute();
                }

                I'll try to (re)create it in a new page.

                Thank you,
                Ruben
                • 5. Re: File upload custom renaming not working with {KT_ext}
                  Level 1
                  Hi Günter,

                  I've created a simple form in a new page, with Update Form Wizard, with only one field, the file one. And now it works...

                  The function is

                  function Trigger_FileUpload(&$tNG) {
                  $uploadObj = new tNG_FileUpload($tNG);
                  $uploadObj->setFormFieldName("mp3");
                  $uploadObj->setDbFieldName("mp3");
                  $uploadObj->setFolder("../mp3/");
                  $uploadObj->setMaxSize(4000);
                  $uploadObj->setAllowedExtensions("mp3");
                  $uploadObj->setRename("custom");
                  $uploadObj->setRenameRule("{GET.id_cd}_{id_track}.{KT_ext}");
                  return $uploadObj->Execute();
                  }

                  I don't understand why, but it seems to work. So I'll add the other fields by hand, and this page will be the update page.

                  Thank you!
                  Ruben
                  • 6. Re: File upload custom renaming not working with {KT_ext}
                    Günter Schenk Level 4
                    Hi Ruben,

                    well, the only difference between both code samples seems to be "{track}" vs. "{id_track}" in the "setRenameRule" line -- as you initially seem to have implemented more than a file field (what would work), is it possible you just picked up the wrong field ?

                    Günter Schenk
                    Adobe Community Expert, Dreamweaver
                    • 7. Re: File upload custom renaming not working with {KT_ext}
                      Level 1
                      Hi Günter,

                      {track} and {id_track} are both table fields, and setRenameRule worked right with both, but it didn't with {KT_ext}.

                      I've changed {track} with {id_track} in first page, and it stills fail to put extension.

                      But maybe is this, in first page the column for Update Transaction is like this

                      $upd_cds_peces->addColumn("mp3", "FILE_TYPE", "POST", "mp3");

                      and in the second page (where it works right) is

                      $upd_cds_peces->addColumn("mp3", "FILE_TYPE", "FILES", "mp3");

                      Althought in both cases the file is uploaded and DDBB field is filled, maybe in first case the TNG doesn't expect a file and cannot find its extension.

                      I'll try to change it,
                      thanks,
                      Ruben

                      Edit: Yes, it was this... Now it works. Thank you Günter for your help!