Skip to content

Commit 1c945cc

Browse files
committed
Fix attachments being lost on error
Fixes #189
1 parent 1283120 commit 1c945cc

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

sd_source/SimpleDesk-Post.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1738,6 +1738,11 @@ function shd_check_attachments()
17381738
continue;
17391739
}
17401740

1741+
if (!file_exists($current_attach_dir . '/' . $attachID)) {
1742+
unset($_SESSION['temp_attachments'][$attachID]);
1743+
continue;
1744+
}
1745+
17411746
$quantity++;
17421747
$total_size += filesize($current_attach_dir . '/' . $attachID);
17431748

@@ -2003,7 +2008,12 @@ function shd_handle_attachments()
20032008
continue;
20042009
}
20052010

2006-
$_FILES['attachment' . $attachID]['tmp_name'] = $attachID;
2011+
if (!file_exists($current_attach_dir . '/' . $attachID)) {
2012+
unset($_SESSION['temp_attachments'][$attachID]);
2013+
continue;
2014+
}
2015+
2016+
$_FILES['attachment' . $attachID]['tmp_name'] = $current_attach_dir . '/' . $attachID;
20072017
$_FILES['attachment' . $attachID]['name'] = $name;
20082018
$_FILES['attachment' . $attachID]['size'] = filesize($current_attach_dir . '/' . $attachID);
20092019
list ($_FILES['attachment' . $attachID]['width'], $_FILES['attachment' . $attachID]['height']) = @getimagesize($current_attach_dir . '/' . $attachID);

0 commit comments

Comments
 (0)