diff --git a/modules/upload.module b/modules/upload.module
index 98cd8c2fc509cfced861289eddf8ab1a74f5984c..5b22a1f96697a0ad448183bad89f967a41206d21 100644
--- a/modules/upload.module
+++ b/modules/upload.module
@@ -381,8 +381,8 @@ function _upload_validate(&$node) {
             form_set_error('upload', t('The selected file %name can not be attached to this post, because the disk quota of %quota has been reached.', array('%name' => theme('placeholder', $file->filename), '%quota' => theme('placeholder', format_size($usersize)))));
             $valid = FALSE;
           }
-          elseif (strlen($node->files[$fid]->filename) > 255) {
-            form_set_error('upload', t('The selected file %name can not be attached to this post, because the filename is too long.', array('%name' => theme('placeholder', $munged_filename))));
+          elseif (strlen($file->filename) > 255) {
+            form_set_error('upload', t('The selected file %name can not be attached to this post, because the filename is too long.', array('%name' => theme('placeholder', $file->filename))));
             $valid = FALSE;
           }
 
diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index 98cd8c2fc509cfced861289eddf8ab1a74f5984c..5b22a1f96697a0ad448183bad89f967a41206d21 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -381,8 +381,8 @@ function _upload_validate(&$node) {
             form_set_error('upload', t('The selected file %name can not be attached to this post, because the disk quota of %quota has been reached.', array('%name' => theme('placeholder', $file->filename), '%quota' => theme('placeholder', format_size($usersize)))));
             $valid = FALSE;
           }
-          elseif (strlen($node->files[$fid]->filename) > 255) {
-            form_set_error('upload', t('The selected file %name can not be attached to this post, because the filename is too long.', array('%name' => theme('placeholder', $munged_filename))));
+          elseif (strlen($file->filename) > 255) {
+            form_set_error('upload', t('The selected file %name can not be attached to this post, because the filename is too long.', array('%name' => theme('placeholder', $file->filename))));
             $valid = FALSE;
           }