You are here

function _filefield_widget_settings_file_path_validate in FileField 6.3

Same name and namespace in other branches
  1. 6.2 filefield.module \_filefield_widget_settings_file_path_validate()
1 string reference to '_filefield_widget_settings_file_path_validate'
filefield_widget_settings_form in ./filefield_widget.inc
Implementation of CCK's hook_widget_settings($op == 'form').

File

./filefield_widget.inc, line 117
This file contains CCK widget related functionality.

Code

function _filefield_widget_settings_file_path_validate($element, &$form_state) {

  // Strip slashes from the beginning and end of $widget['file_path']
  $form_state['values']['file_path'] = trim($form_state['values']['file_path'], '\\/');

  // Do not allow the file path to be the same as the file_directory_path().
  // This causes all sorts of problems with things like file_create_url().
  if (strpos($form_state['values']['file_path'], file_directory_path()) === 0) {
    form_error($element, t('The file path (@file_path) cannot start with the system files directory (@files_directory), as this may cause conflicts when building file URLs.', array(
      '@file_path' => $form_state['values']['file_path'],
      '@files_directory' => file_directory_path(),
    )));
  }
}