diff --git a/mod/assignment/type/upload/lang/en/assignment_upload.php b/mod/assignment/type/upload/lang/en/assignment_upload.php
index cd69e73..3bbbc05 100644
--- a/mod/assignment/type/upload/lang/en/assignment_upload.php
+++ b/mod/assignment/type/upload/lang/en/assignment_upload.php
@@ -23,4 +23,6 @@
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+$string['nofileerror'] = 'No file was selected. Please select a file to upload.';
 $string['pluginname'] = 'Upload';
+
diff --git a/mod/assignment/type/uploadsingle/assignment.class.php b/mod/assignment/type/uploadsingle/assignment.class.php
index 08cd006..c5976db 100644
--- a/mod/assignment/type/uploadsingle/assignment.class.php
+++ b/mod/assignment/type/uploadsingle/assignment.class.php
@@ -212,36 +212,36 @@
                 }
             }
 
-            if ($formdata = $mform->get_data()) {
+            $newfilename = $mform->get_new_filename('assignment_file'); //only if a file exixts a file name is generated
+
+            if ($formdata = $mform->get_data() && $newfilename) {       //checks whether the form data is valid and a file exists
                 $fs = get_file_storage();
                 $submission = $this->get_submission($USER->id, true); //create new submission if needed
                 $fs->delete_area_files($this->context->id, 'mod_assignment', 'submission', $submission->id);
+                $file = $mform->save_stored_file('assignment_file', $this->context->id, 'mod_assignment', 'submission',
+                      $submission->id, '/', $newfilename);
+                $updates = new stdClass(); //just enough data for updating the submission
+                $updates->timemodified = time();
+                $updates->numfiles     = 1;
+                $updates->id     = $submission->id;
+                $DB->update_record('assignment_submissions', $updates);
+                add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a='.$this->assignment->id, $this->assignment->id, $this->cm->id);
+                $this->update_grade($submission);
+                $this->email_teachers($submission);
 
-                if ($newfilename = $mform->get_new_filename('assignment_file')) {
-                    $file = $mform->save_stored_file('assignment_file', $this->context->id, 'mod_assignment', 'submission',
-                        $submission->id, '/', $newfilename);
-
-                    $updates = new stdClass(); //just enough data for updating the submission
-                    $updates->timemodified = time();
-                    $updates->numfiles     = 1;
-                    $updates->id     = $submission->id;
-                    $DB->update_record('assignment_submissions', $updates);
-                    add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a='.$this->assignment->id, $this->assignment->id, $this->cm->id);
-                    $this->update_grade($submission);
-                    $this->email_teachers($submission);
-
-                    // Let Moodle know that an assessable file was uploaded (eg for plagiarism detection)
-                    $eventdata = new stdClass();
-                    $eventdata->modulename   = 'assignment';
-                    $eventdata->cmid         = $this->cm->id;
-                    $eventdata->itemid       = $submission->id;
-                    $eventdata->courseid     = $this->course->id;
-                    $eventdata->userid       = $USER->id;
-                    $eventdata->file         = $file;
-                    events_trigger('assessable_file_uploaded', $eventdata);
-                }
+                // Let Moodle know that an assessable file was uploaded (eg for plagiarism detection)
+                $eventdata = new stdClass();
+                $eventdata->modulename   = 'assignment';
+                $eventdata->cmid         = $this->cm->id;
+                $eventdata->itemid       = $submission->id;
+                $eventdata->courseid     = $this->course->id;
+                $eventdata->userid       = $USER->id;
+                $eventdata->file         = $file;
+                events_trigger('assessable_file_uploaded', $eventdata);
 
                 redirect($viewurl, get_string('uploadedfile'));
+            }else if($mform->get_data()){
+                redirect($viewurl, get_string('nofileerror', 'assignment'));  //No file has been selected
             } else {
                 redirect($viewurl, get_string('uploaderror', 'assignment'));  //submitting not allowed!
             }