Filter Out Filenames by Extension

Last post 06-08-2007, 3:06 PM by Judge. 6 replies.
Sort Posts: Previous Next
  •  06-08-2007, 11:04 AM 30510

    Filter Out Filenames by Extension

    Can you give me an example of a regular expression for the filenamePattern property that will filter out certain filetypes? (ie: filter out *.exe, *.test)
     
    Thanks.
  •  06-08-2007, 11:40 AM 30513 in reply to 30510

    Re: Filter Out Filenames by Extension

  •  06-08-2007, 11:57 AM 30515 in reply to 30513

    Re: Filter Out Filenames by Extension

    That works for 'downloadable files', but I want to restrict what's displayed when they 'insert hyperlink'.  I need to modify the filenamePattern for that, correct?
  •  06-08-2007, 12:17 PM 30516 in reply to 30515

    Re: Filter Out Filenames by Extension

    >>That works for 'downloadable files', but I want to restrict what's displayed when they 'insert hyperlink'. 
     
    It also works for  'insert hyperlink' button.
     
     
    >>I need to modify the filenamePattern for that, correct?
     
    No.
     

    Restricting Document Files by Extensions and Types

     

    One of the CuteEditor new and innovative capabilities is restricting uploading Document Files by extensions and types. You can filter the type of Document Files so only specified file types are allowed to upload or show in the dialog.

    This topic describes how to manage uploading document file type restrictions.

     

      

     

    You can restrict uploading document Files by Extensions and Types by editing the security policy file:


    The security policy file (default.config, admin.config and guest.config) can be found in the /CuteEditor/Configuration/Security folder. In security policy file you can find the DocumentFilters element element . By default, it contains the following value:


    <
    security name="DocumentFilters">

           <item>.pdf</item>
           <item>.zip</item>

           <item>.rar</item>

    </security>
      

    You can modify the DocumentFilters element element to meet your own requirements.  

     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  06-08-2007, 2:07 PM 30526 in reply to 30516

    Re: Filter Out Filenames by Extension

    That's not working for me.  All I have in my DocumentFilters is <item>.pdf</item> and <item>.doc</item> but when I 'insert hyperlink', it still shows me all files.
     
    I know I can use filenamePattern to do what I want, I'm already using it to block out filenames that begin with an underscore (ie: <security name="filenamePattern">^[^_][a-zA-Z0-9\._\s-]+$</security>).
     
    If you have regular expression expertise, please provide me with an expression to block out a file extension.  I'm looking for something like <security name="filenamePattern">^.+\.[^(inc)]*$</security>, but this isn't quite right, it blocks all files with an 'i', 'n' or 'c' in the extension instead of the exact 'inc' extension.
  •  06-08-2007, 2:47 PM 30527 in reply to 30526

    Re: Filter Out Filenames by Extension

    Please open CuteSoft_Client\CuteEditor\Dialogs\SelectFile.aspx and find the following code:
     
      protected override void GetFiles(ArrayList files)
        {
      files.AddRange(fs.GetFileItems(CurrentDirectory,secset.FileNamePrefix + "*.*"));
        }
     
    Change it to:
     

        protected override void GetFiles(ArrayList files)
        {  
            foreach (string ext in secset.DocumentFilters)
            {
                if (ext == null || ext.Length == 0) continue;
               
       if ( ext.Length > 4 )
       {
        if ( !secset.DocumentFilters.Contains( ext.Substring( 0, 4 ) ) )
        {
         files.AddRange(fs.GetFileItems(CurrentDirectory, secset.FileNamePrefix + "*" + ext));    
        }
        
       }
       else
        files.AddRange(fs.GetFileItems(CurrentDirectory, secset.FileNamePrefix + "*" + ext));
            }       
           
        }
     
    Keep me posted
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  06-08-2007, 3:06 PM 30528 in reply to 30527

    Re: Filter Out Filenames by Extension

    That worked, the DocumentFilters now applies to the 'insert hyperlink' dialog too.  I also found this RegEx that will block file extensions in case anyone is interested (ie: blocks all files with abc or xyz extensions; add more as needed):
    ^[a-zA-Z0-9_\s-]+\.(?!abc)(?!xyz).+$
     
    Thanks again.
     
     
View as RSS news feed in XML