--- C:/Temp/p4v/laptop-weibel_localhost_1667/depot/newlifebern/main/sites/all/modules/media_mover/contrib/mm_cck/mm_cck#4.module Mon Dec 12 21:59:57 2011 +++ d:/Wamp/www/newlifebern/main/sites/all/modules/media_mover/contrib/mm_cck/mm_cck.module Mon Dec 12 22:26:14 2011 @@ -465,16 +465,17 @@ // save the new node to prepare to add the CCK data node_save($node); $file['nid'] = $node->nid; } // Now copy the file to the new location - if (! file_copy($local_file, mm_cck_field_widget_files_directory($field))) { - watchdog('MM CCK', 'Failed to copy. %data', array('%data' => "Source: $filepath Destination: $local_file"), WATCHDOG_ERROR); + $destination = mm_cck_field_widget_files_directory($field); + if (! file_copy($local_file, $destination)) { + watchdog('MM CCK', 'Failed to copy. %data', array('%data' => "Source: $local_file; Destination: $destination"), WATCHDOG_ERROR); return false; } // we need to add an new file to the node switch ($field['type']) { case 'text': $node->{$field['field_name']} = array(array('value' => $local_file)); @@ -526,14 +527,20 @@ // get the validators for this field if ($field['type'] == 'image') { $validators = array_merge(filefield_widget_upload_validators($field), imagefield_widget_upload_validators($field)); } else { $validators = filefield_widget_upload_validators($field);} + if (!empty($field['widget']['max_filesize_per_file'])) { + // Overwrite the max filesize when it is set. + $max_filesize = parse_size($field['widget']['max_filesize_per_file']); + $validators['filefield_validate_size'] = array($max_filesize); + } + // now get the new field if (! $new_file = field_file_save_file($filepath, $validators, $destination_path)) { watchdog('MM CCK', 'Could not save file with field_file_save_file() %file', array('%file' => print_r($file, true)), WATCHDOG_ERROR); return; } // we need to alter the file object slightly so it will display correctly @@ -574,17 +581,20 @@ if (module_exists('token')) { global $user; $path = token_replace($path, 'user', $user); } $path = '/'. $path; } // Allways return a good path - $path = file_directory_path() . $path; - file_check_directory($path, FILE_CREATE_DIRECTORY); - return $path; + $full_path = file_directory_path(); + foreach (explode('/', $path) as $part) { + $full_path .= '/'. $part; + file_check_directory($full_path, FILE_CREATE_DIRECTORY); + } + return $full_path; } /** * Return array of content fields for display in configuration forms. */ function mm_cck_fields() {