diff --git a/modules/file/file.field.inc b/modules/file/file.field.inc index d592381..eb664d9 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]', 'max_filesize' => '', 'description_field' => 0, ), diff --git a/modules/file/tests/file.test b/modules/file/tests/file.test index 41e97cd..432061b 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) . '/' . $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..f0dbf27 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]', 'max_filesize' => '', 'alt_field' => 0, 'title_field' => 0, diff --git a/modules/system/system.install b/modules/system/system.install index ae55b89..e1553cc 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]', 'description_field' => 1, ), 'display' => array( diff --git a/profiles/standard/standard.install b/profiles/standard/standard.install index ae34eaf..158c4ea 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]', 'file_extensions' => 'png gif jpg jpeg', 'max_filesize' => '', 'max_resolution' => '',