You are here

function linkimagefield_check_directory in Link Image Field 5

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 linkimagefield_check_directory()
linkimagefield_file_insert in ./linkimagefield.module
insert a file into the database.
linkimagefield_form_check_directory in ./linkimagefield.module
Wrapper function for linkimagefield_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

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

Code

function linkimagefield_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;
}