diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 204a48f..c03449e 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -625,7 +625,13 @@ function file_managed_file_save_upload($element) { return FALSE; } - $destination = isset($element['#upload_location']) ? $element['#upload_location'] : NULL; + if (isset($element['#upload_location'])) { + $destination = $element['#upload_location'] . '/' . date("Y") . '/' . date("m"); + } + else { + $destination = NULL; + } + if (isset($destination) && !file_prepare_directory($destination, FILE_CREATE_DIRECTORY)) { watchdog('file', 'The upload directory %directory for the file field !name could not be created or is not accessible. A newly uploaded file could not be saved in this directory as a consequence, and the upload was canceled.', array('%directory' => $destination, '!name' => $element['#field_name'])); form_set_error($upload_name, t('The file could not be uploaded.'));