Attachment Validation ?_?

Started by cristianlf, January 19, 2011, 04:17:23 PM

Previous topic - Next topic

cristianlf

Hello every1 

I was trying to validate that the attachment files were .zip, .rar, etc so I change the default and add the files I want,

then I try it, but do not work :S  some advise where to look ???

Regards.

cristianlf

Hello the this is the fucntion that is not working properly: 

<script type="text/javascript"><!-- // --><![CDATA[
   var oAttach = new shd_attach_select({
      file_item: "shd_attach",
      file_container: "shd_attachlist_container",
      max: ', $context['ticket_form']['num_allowed_attachments'], ',
      message_txt_delete: ', JavaScriptEscape($txt['remove']);
      
      if (!empty($modSettings['attachmentExtensions']) && !empty($modSettings['attachmentCheckExtensions']))
      {
         $ext = explode(',', $modSettings['attachmentExtensions']);
         foreach ($ext as $k => $v)
            $ext[$k] = JavaScriptEscape($v);

         echo ',
      message_ext_error: ', JavaScriptEscape(str_replace('{attach_exts}', $context['allowed_extensions'], $txt['shd_cannot_attach_ext'])), ',
      attachment_ext: [', implode(',', $ext), ']';
      }


      echo '
   });
                  // ]]></script>';
   }


well I would try to fix it, then  I comment,  if someone know how to solve this problem be my guest and post it ...

cristianlf

Ok there is a lot of thing to do here -_- 
I had  to change  the helpdesk.js  to validate the extension i want,
but there is an error in this funtion  ...
var func = Array.prototype.indexOf ?
      function(arr, obj) { return arr.indexOf(obj) !== -1; } :
      function(arr, obj) {
         for(var i = -1, j = arr.length; ++i < j;)
            if(arr === obj) return true;
         return false;
    };

well I will keep trying ...

Gruffen

What exactly are you trying to do with the function?

If you want to limit the files to being given extensions, set that in the admin panel under Attachments and Avatars.

cristianlf

Quote from: Gruffen on January 20, 2011, 02:14:40 PM
What exactly are you trying to do with the function?

If you want to limit the files to being given extensions, set that in the admin panel under Attachments and Avatars.

well thats the problem I already try this, but nothing happended .... so I have to see the code and  I found this ... so dunno why this is happening ...

regards,

Gruffen

It works just fine for me (except in IE where it doesn't clear the file input selector on wrong extension)

cristianlf

mm ok I think I forgot to check somethig at the page of attachments ...

my  mistake ...   


thanks.