diff --git a/filefield.module b/filefield.module index fe54421142c7177475aeee4542e85f554e86bda2..23f7c2b688d13d21d6f70b68a9bb845ab116b835 100644 --- a/filefield.module +++ b/filefield.module @@ -561,6 +561,31 @@ function filefield_file_upload(&$form_state, $field, $delta) { return $file; } +/** + * Create the file directory relative to the 'files' dir recursively for every + * directory in the path. + * + * @param $directory + * The directory path under files to check, such as 'photo/path/here'. + * @param $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.) + */ +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; +} + + /** * The filefield widget for previously uploaded files. */ @@ -1187,30 +1212,6 @@ function filefield_file_download($file) { ); } -/** - * Create the file directory relative to the 'files' dir recursively for every - * directory in the path. - * - * @param $directory - * The directory path under files to check, such as 'photo/path/here' - * @param $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.) - */ -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; -} - /** * Implementation of hook_token_list():