You are here

function imagefield_check_directory in ImageField 5

Same name and namespace in other branches
  1. 5.2 imagefield.module \imagefield_check_directory()

Create the image 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

2 calls to imagefield_check_directory()
imagefield_file_insert in ./imagefield.module
insert a file into the database.
imagefield_form_check_directory in ./imagefield.module
Wrapper function for imagefield_check_directory that accepts a form element to validate - if user specified one. Won't allow form submit unless the directory exists & is writable

File

./imagefield.module, line 307
Defines an image field type. imagefield uses content.module to store the fid, and the drupal files table to store the actual file data.

Code

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