diff --git a/modules/file/file.field.inc b/modules/file/file.field.inc index d592381..b267f51 100644 --- a/modules/file/file.field.inc +++ b/modules/file/file.field.inc @@ -20,7 +20,7 @@ function file_field_info() { ), 'instance_settings' => array( 'file_extensions' => 'txt', - 'file_directory' => '', + 'file_directory' => '[date:custom:Y]/[date:custom:m]/[date:custom:d]', 'max_filesize' => '', 'description_field' => 0, ), diff --git a/modules/file/tests/file.test b/modules/file/tests/file.test index b3a1424..a7e5d81 100644 --- a/modules/file/tests/file.test +++ b/modules/file/tests/file.test @@ -1354,10 +1354,11 @@ class FileFieldPathTestCase extends FileFieldTestCase { // Create a new node. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); - // Check that the file was uploaded to the file root. + // Check that the file was uploaded to the correct location. $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertPathMatch('public://' . $test_file->filename, $node_file->uri, format_string('The file %file was uploaded to the correct path.', array('%file' => $node_file->uri))); + $expected_path = 'public://' . date('Y', REQUEST_TIME) . '/' . date('m', REQUEST_TIME) . '/' . date('d', REQUEST_TIME) . '/' . $test_file->filename; + $this->assertPathMatch($expected_path, $node_file->uri, format_string('The file %file was uploaded to the correct path.', array('%file' => $node_file->uri))); // Change the path to contain multiple subdirectories. $field = $this->updateFileField($field_name, $type_name, array('file_directory' => 'foo/bar/baz')); diff --git a/modules/image/image.field.inc b/modules/image/image.field.inc index 6d1867c..24941bc 100644 --- a/modules/image/image.field.inc +++ b/modules/image/image.field.inc @@ -19,7 +19,7 @@ function image_field_info() { ), 'instance_settings' => array( 'file_extensions' => 'png gif jpg jpeg', - 'file_directory' => '', + 'file_directory' => '[date:custom:Y]/[date:custom:m]/[date:custom:d]', 'max_filesize' => '', 'alt_field' => 0, 'title_field' => 0, diff --git a/modules/system/system.install b/modules/system/system.install index d5e6743..c65d34b 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -2782,7 +2782,7 @@ function system_update_7060() { 'settings' => array( 'max_filesize' => $upload_size ? ($upload_size . ' MB') : '', 'file_extensions' => variable_get('upload_extensions_default', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp'), - 'file_directory' => '', + 'file_directory' => '[date:custom:Y]/[date:custom:m]/[date:custom:d]', 'description_field' => 1, ), 'display' => array( diff --git a/profiles/standard/standard.install b/profiles/standard/standard.install index ae34eaf..fe06b83 100644 --- a/profiles/standard/standard.install +++ b/profiles/standard/standard.install @@ -356,7 +356,7 @@ function standard_install() { 'required' => FALSE, 'settings' => array( - 'file_directory' => 'field/image', + 'file_directory' => '[date:custom:Y]/[date:custom:m]/[date:custom:d]', 'file_extensions' => 'png gif jpg jpeg', 'max_filesize' => '', 'max_resolution' => '',