diff --git a/include/class.forms.php b/include/class.forms.php
index 4a447cd14bcd0def2ed14a24892983b5023fc62c..4252be233d1a6ac056ed10992c3ed6f67888f766 100644
--- a/include/class.forms.php
+++ b/include/class.forms.php
@@ -3909,26 +3909,14 @@ class FileUploadWidget extends Widget {
         $config = $this->field->getConfiguration();
         $name = $this->field->getFormName();
         $id = substr(md5(spl_object_hash($this)), 10);
-        $attachments = $this->field->getAttachments();
         $mimetypes = array_filter($config['__mimetypes'],
             function($t) { return strpos($t, '/') !== false; }
         );
         $maxfilesize = ($config['size'] ?: 1048576) / 1048576;
         $files = array();
         $new = array_fill_keys($this->field->getClean(), 1);
-        foreach ($attachments as $a) {
-            unset($new[$a->file_id]);
-        }
-        // Add in newly added files not yet saved (if redisplaying after an
-        // error)
-        if ($new) {
-            $attachments = array_merge($attachments, GenericAttachment::objects()
-                ->filter(array('file_id__in' => array_keys($new)))
-                ->all()
-            );
-        }
-
-        foreach ($attachments as $att) {
+        foreach ($this->field->getAttachments() as $att) {
+            unset($new[$att->file_id]);
             $files[] = array(
                 'id' => $att->file->getId(),
                 'name' => $att->getFilename(),
@@ -3937,6 +3925,25 @@ class FileUploadWidget extends Widget {
                 'download_url' => $att->file->getDownloadUrl(),
             );
         }
+
+        // Add in newly added files not yet saved (if redisplaying after an
+        // error)
+        if ($new) {
+            $F = AttachmentFile::objects()
+                ->filter(array('id__in' => array_keys($new)))
+                ->all();
+            foreach ($F as $f) {
+                $f->tmp_name = $new[$f->getId()];
+                $files[] = array(
+                    'id' => $f->getId(),
+                    'name' => $f->getName(),
+                    'type' => $f->getType(),
+                    'size' => $f->getSize(),
+                    'download_url' => $f->getDownloadUrl(),
+                );
+            }
+        }
+
         ?><div id="<?php echo $id;
             ?>" class="filedrop"><div class="files"></div>
             <div class="dropzone"><i class="icon-upload"></i>