You are here

function _fb_validate_file_path in Filebrowser 8

@file Validates file path input on node form

Parameters

$file_path String as filled in node form:

Return value

An error-string in case of file path error. Else NULL

1 call to _fb_validate_file_path()
filebrowser_node_validate in ./filebrowser.module

File

./filebrowser.module, line 216
Validates file path input on node form

Code

function _fb_validate_file_path($file_path, $encoding) {
  $encoded_path = _filebrowser_encoding_to_fs($encoding, $file_path);
  if (!is_dir($encoded_path)) {
    $success = mkdir($encoded_path, 0777, TRUE);
    if (!$success) {
      return t('Unable to create directory. It might be invalid.');
    }
    else {
      return false;
    }
  }
  else {
    if (!is_readable($encoded_path)) {
      return t('The directory %dir is not readable.', array(
        '%dir' => $file_path,
      ));
    }
  }
  return false;
}