Webform, rename files to a constant name and bypass validation I have a webform where users can upload one pdf file. I'd like to have this pdf file always the same name foo.pdf.

To avoid conflicts I save each upload to a different directory with the pattern foo/[random:hash:md5].

When trying to save these settings I get the error message To create unique file names, use at least one token in the file name pattern. I understand that this error makes sense to avoid naming conflicts but the conflicts should be avoided with the custom directory.

Is there a way to bypass the validation check?

Edit: For clarification. I need to bypass the validation check in the settings page for the field of the file upload not the validation for the form submission itself
By looking at the source in /components/file.inc (in Webform module), you will see that the Webform declares a custom element validation callback that performs the check you want to avoid. In order to override this, you will have to hook into the settings form, and provide your own callback for this element.

Below is the code you would use to achieve that. Pay attention to the comments.

function YOUR_MODULE_form_webform_component_edit_form_alter(&amp;$form, &amp;$form_state) {
  // Override the element validation callback for renaming the file uploads.
  if (isset($form['extra']['rename'])) {
    // Loop through the validation callbacks and remove the one we want to
    // override. This way we will not affect any other module that alters this
    // part of the form.
    foreach ($form['extra']['rename']['#element_validate'] as $key =&gt; $validation_callback) {
      if ($validation_callback == '_webform_edit_file_rename_validate') {
        unset($form['extra']['rename']['#element_validate'][$key]);
      }
    }
    // Note: since the original validation callback provided in Webform module
    // only makes sure that the file names are unique, you don't need to provide
    // your own element validation callback. However, I would recommend doing so
    // just in case you have other webform nodes that will need this validation.
    //
    // Add our custom element validation callback.
    $form['extra']['rename']['#element_validate'][] = 'YOUR_MODULE_edit_file_rename_validate';
  }
}


function YOUR_MODULE_edit_file_rename_validate($element, &amp;$form_state, $form) {
  // I recommend still limiting this only to specific nodes, content types, and
  // not disabling completely.
  if ($form['#node']-&gt;nid != YOUR_NODE_ID) {
    $rename = trim($form_state['values']['extra']['rename']);
    form_set_value($element, $rename, $form_state);
    if (strlen($rename) &amp;&amp; !count(token_scan($rename))) {
      form_error($element, t('To create unique file names, use at least one token in the file name pattern.'));
    }
  }
}