You are here

function filefield_check_directory in FileField 6.2

Same name and namespace in other branches
  1. 5.2 filefield.module \filefield_check_directory()

Create the file directory relative to the 'files' dir recursively for every directory in the path.

Parameters

$directory: The directory path under files to check, such as 'photo/path/here'.

$form_item: An optional string containing the name of a form item that any errors will be attached to. (See field_file_check_directory() for more details.)

1 call to filefield_check_directory()
_filefield_file_upload in ./filefield.widget.inc
Upload a file to the given field and delta (or try to, at least), and update the corresponding part of the form state with the new file data.

File

./filefield.widget.inc, line 450
FileField: Defines a CCK file field type.

Code

function filefield_check_directory($directory, $form_item = NULL) {
  $directory = field_file_strip_path($directory);
  foreach (explode('/', $directory) as $dir) {
    $dirs[] = $dir;
    $path = file_create_path(implode($dirs, '/'));
    if (!field_file_check_directory($path, FILE_CREATE_DIRECTORY, $form_item)) {
      watchdog('filefield', t('FileField failed to create directory (%d) at (%p).', array(
        '%d' => $directory,
        '%p' => $path,
      )), WATCHDOG_ERROR);
      return FALSE;
    }
  }
  return TRUE;
}