Additional Check for the file

This commit is contained in:
SamBrishes 2020-05-14 17:59:29 +02:00
parent 3dca6efcdc
commit 2e486f6d33
1 changed files with 5 additions and 2 deletions

View File

@ -1,6 +1,9 @@
jQuery(document).ready(function($) { jQuery(document).ready(function($) {
$('#backupFile').change(function() { $('#backupFile').change(function() {
var file = this.files.length >= 1? this.files[0]: null; var file = this.files.length >= 1? this.files[0]: null;
if (file === null) {
return false;
}
// Build Form Data // Build Form Data
var url = $('#jsform').attr("action") || window.location.href; var url = $('#jsform').attr("action") || window.location.href;
@ -17,14 +20,14 @@ jQuery(document).ready(function($) {
mimeType: "multipart/form-data", mimeType: "multipart/form-data",
contentType: false, contentType: false,
processData: false, processData: false,
error: function(jqXHR, status, error) { error: function (jqXHR, status, error) {
var data = jqXHR.responseJSON; var data = jqXHR.responseJSON;
var alert = $("<div></div>").addClass("alert alert-danger").text(data.message); var alert = $("<div></div>").addClass("alert alert-danger").text(data.message);
$("#jsform .alert:not(.alert-primary)").remove(); $("#jsform .alert:not(.alert-primary)").remove();
$("#jstokenCSRF").after(alert); $("#jstokenCSRF").after(alert);
}, },
success: function(data, status, jqXHR) { success: function (data, status, jqXHR) {
window.location.reload(); window.location.reload();
} }
}); });