diff --git a/mod/assignment/type/upload/assignment.class.php b/mod/assignment/type/upload/assignment.class.php
index cdb052c..22a30ee 100644
--- a/mod/assignment/type/upload/assignment.class.php
+++ b/mod/assignment/type/upload/assignment.class.php
@@ -571,7 +571,6 @@ class assignment_upload extends assignment_base {
 
         $returnurl = 'view.php?id='.$this->cm->id;
 
-        $filecount = $this->count_user_files($USER->id);
         $submission = $this->get_submission($USER->id);
 
         if (!$this->can_upload_file($submission)) {
@@ -589,10 +588,12 @@ class assignment_upload extends assignment_base {
         $um = new upload_manager('newfile',false,true,$this->course,false,$this->assignment->maxbytes,true);
 
         if ($um->process_file_uploads($dir)) {
+            $filecount = $this->count_user_files($USER->id);
             $submission = $this->get_submission($USER->id, true); //create new submission if needed
             $updated = new object();
             $updated->id           = $submission->id;
             $updated->timemodified = time();
+            $updated->numfiles     = $filecount;
 
             if (update_record('assignment_submissions', $updated)) {
                 add_to_log($this->course->id, 'assignment', 'upload',
@@ -830,9 +831,11 @@ class assignment_upload extends assignment_base {
         $filepath = $CFG->dataroot.'/'.$dir.'/'.$file;
         if (file_exists($filepath)) {
             if (@unlink($filepath)) {
+                $filecount = $this->count_user_files($userid);
                 $updated = new object();
                 $updated->id = $submission->id;
                 $updated->timemodified = time();
+                $updated->numfiles = $filecount;
                 if (update_record('assignment_submissions', $updated)) {
                     add_to_log($this->course->id, 'assignment', 'upload', //TODO: add delete action to log
                             'view.php?a='.$this->assignment->id, $this->assignment->id, $this->cm->id);
