You are here

function filefield_paths_settings_form_temp_location_validate in File (Field) Paths 7

Validation callback for 'Temporary file location' setting.

Parameters

$element:

$form_state:

Return value

bool

1 call to filefield_paths_settings_form_temp_location_validate()
filefield_paths_variable_temp_location_validate in ./filefield_paths.variable.inc
Validate callback for 'Temporary file location' variable.
1 string reference to 'filefield_paths_settings_form_temp_location_validate'
filefield_paths_settings_form in ./filefield_paths.admin.inc
_state

File

./filefield_paths.admin.inc, line 33
Administration functions for the File (Field) Paths module.

Code

function filefield_paths_settings_form_temp_location_validate($element, $form_state) {
  $scheme = file_uri_scheme($element['#value']);
  if (!$scheme) {
    form_error($element, t('Invalid file location. You must include a file stream wrapper (e.g., public://).'));
    return FALSE;
  }
  if (!file_stream_wrapper_valid_scheme($scheme)) {
    form_error($element, t('Invalid file stream wrapper.'));
    return FALSE;
  }
  if ((!is_dir($element['#value']) || !is_writable($element['#value'])) && !file_prepare_directory($element['#value'], FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
    form_error($element, t('File location can not be created or is not writable.'));
    return FALSE;
  }
}