Skip to main content

Limit Uploaded Files To Regular Expression

This setting limits uploaded file names to a specified regular expression, helping maintain a consistent naming pattern for incoming files. It enhances security by restricting uploads to specific file types, names, or formats, reducing errors, and making sure that only the intended files are uploaded. Applying specific naming rules also supports automation processes and improves compatibility with downstream systems.

In workflows that require both speed and accuracy, especially within large and complex folder structures, maintaining order can be challenging. Without clear naming conventions, misplaced or incorrectly named files can slow down operations, increase the risk of human error, and disrupt automated processes.

Using regular expression rules helps keep files properly named and in the correct locations, reducing confusion and making file management more efficient. This is particularly useful in environments where files need to be routed correctly, such as compliance-driven industries, financial reporting, or regulated data environments.

You can use this setting in many ways, such as when collecting documents through inboxes and share links or when restricting internal and external systems, remote servers, vendors, and internal users to upload files in a specific format.

If you want to limit uploaded files to a certain file name length, you can use the folder setting Limit Uploaded Files to File Name Length. Similarly, you can use the folder settings Limit Uploaded Files to Certain File Extensions and Automatically Rename Uploaded Files.

Your chosen settings will apply to all subfolders within this folder by default unless overridden. Note that moving or copying folders into destinations with filename restrictions, such as those using regular expressions, is not allowed.

Example Regular Expressions

Here are some examples of how regular expressions can be used to control file uploads by restricting filenames based on specific patterns. You can build your own regex based on your specific use case to enforce file naming conventions that align with your requirements.

Restrict filenames to start with a number

If you want to allow only filenames that begin with a number, use ^[0-9].*$. This is useful when managing files that follow a numeric-based naming convention, such as invoices, order numbers, or batch files.

Enforce a case-insensitive invoice naming format

If you need uploaded files to follow an invoice naming structure like INV-1234.pdf, use (?i)^INV-\d{4}\.pdf$. This allows flexibility in uppercase or lowercase while ensuring the correct structure for document categorization.

Limit filenames to lowercase letters, numbers, and specific symbols

For filenames that should only contain lowercase letters, numbers, dots, underscores, or hyphens, use ^[a-z0-9._-]+$. This is useful in environments where uppercase letters are not allowed for consistency.

Restrict filenames to a maximum length

If filenames should not exceed a specific number of characters, use ^.{1,20}$ to limit them to a maximum of 20 characters. This helps in systems that have filename length restrictions or when keeping filenames concise. You can get the similar results using the folder setting Limit Uploaded Files by File Name Length.

Allow filenames with alphanumeric characters and a single dot for extensions

To enforce filenames containing only letters, numbers, spaces, underscores, and hyphens with a single dot for file extensions, use ^[a-zA-Z0-9 _-]+\.[a-zA-Z0-9]+$. This ensures the filename follows a structured format while allowing standard extensions.

Allow only specific file types

To restrict uploads to only certain file types like .jpg, .png, or .txt, use ^.*\.(jpg|png|txt)$. This ensures that users can only upload images or text files and prevents unsupported formats from being added. You can get the similar results using the folder setting Limit Uploaded Files to Certain Extensions.

Prevent filenames from containing restricted characters

If you need to block filenames with characters that are not allowed in certain operating systems, such as < > : " / \ | ? *, use ^[^<>:"/\\|?*]+$. This prevents errors when storing files on Windows-based systems or other restricted environments.

Enforce a specific file name format

To require uploaded files to follow the naming pattern invoice_YYYY-MM-DD.pdf, use: ^invoice_\d{4}-\d{2}-\d{2}\.pdf$. This ensures that only files like invoice_2025-02-01.pdf are allowed, enforcing a standardized format for invoice uploads.

Allow only numeric file names with a specific extension

To restrict file uploads to only numeric file names ending in .log, use: ^\d+\.log$. This allows files such as 12345.log but rejects filenames containing letters, ensuring consistency for log file naming.

Overriding Settings in Subfolders or Excluding Subfolders Entirely

You can override or exclude this setting entirely for subfolders. Users with administrator privileges can customize the restrictions independently of the parent folder. To exclude or override a subfolder from the parent's file name restrictions, an admin with adequate privileges can navigate to the subfolder's settings and select the option Limit uploaded files to regular expression to set unique regular expression for that folder or override the parent folder's settings.

Get Instant Access to Files.com

The button below will take you to our Free Trial signup page. Click on the white "Start My Free Trial" button, then fill out the short form on the next page. Your account will be activated instantly. You can dive in and start yourself or let us help. The choice is yours.