You are here

function filefield_check_directory in FileField 5.2

Same name and namespace in other branches
  1. 6.2 filefield.widget.inc \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_element: A form element to throw an error on if the directory is not writable

1 call to filefield_check_directory()
filefield_file_insert in ./filefield.module
insert a file into the database.

File

./filefield.module, line 855
Defines a file field type.

Code

function filefield_check_directory($directory, $form_element = array()) {
  foreach (explode('/', $directory) as $dir) {
    $dirs[] = $dir;
    $path = file_create_path(implode($dirs, '/'));
    if (!file_check_directory($path, FILE_CREATE_DIRECTORY, $form_element['#parents'][0])) {
      return FALSE;
    }
  }
  return TRUE;
}