summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/user/user.module5
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/user/user.module b/modules/user/user.module
index 10f3978ce..215a7372f 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -391,6 +391,11 @@ function user_validate_picture(&$form, &$form_state) {
'file_validate_size' => array(variable_get('user_picture_file_size', '30') * 1024),
);
if ($file = file_save_upload('picture_upload', $validators)) {
+ // Remove the old picture.
+ if (isset($form_state['values']['_account']->picture) && file_exists($form_state['values']['_account']->picture)) {
+ file_delete($form_state['values']['_account']->picture);
+ }
+
// The image was saved using file_save_upload() and was added to the
// files table as a temporary file. We'll make a copy and let the garbage
// collector delete the original upload.