- $attachment = array(
- 'path' => $filepath,
- 'size' => $_FILES['_attachments']['size'][$i],
- 'name' => $_FILES['_attachments']['name'][$i],
- 'mimetype' => rc_mime_content_type($filepath, $_FILES['_attachments']['name'][$i], $_FILES['_attachments']['type'][$i])
- );
-
- $attachment = $RCMAIL->plugins->exec_hook('attachment_upload', $attachment);
+ // Process uploaded attachment if there is no error
+ $err = $_FILES['_attachments']['error'][$i];
+
+ if (!$err) {
+ $attachment = array(
+ 'path' => $filepath,
+ 'size' => $_FILES['_attachments']['size'][$i],
+ 'name' => $_FILES['_attachments']['name'][$i],
+ 'mimetype' => rc_mime_content_type($filepath, $_FILES['_attachments']['name'][$i], $_FILES['_attachments']['type'][$i]),
+ 'group' => $COMPOSE_ID,
+ );
+
+ $attachment = $RCMAIL->plugins->exec_hook('attachment_upload', $attachment);
+ }