function imagefield_check_directory in ImageField 5.2
Same name and namespace in other branches
- 5 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
3 calls to imagefield_check_directory()
- imagefield_field_settings in ./
imagefield.module - Implementation of hook_field_settings().
- imagefield_file_insert in ./
imagefield.module - Insert a file into the database.
- _imagefield_widget_prepare_form_values in ./
imagefield.module
File
- ./
imagefield.module, line 507 - 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, '/'));
if (!file_check_directory($path, FILE_CREATE_DIRECTORY, $form_element['#parents'][0])) {
watchdog('imagefield', t('Imagefield failed to create directory(%d) at (%p).', array(
'%d' => $directory,
'%p' => $path,
)), WATCHDOG_ERROR);
return false;
}
}
return true;
}