2020-05-14 17:35:46 +02:00
|
|
|
jQuery(document).ready(function($) {
|
|
|
|
$('#backupFile').change(function() {
|
|
|
|
var file = this.files.length >= 1? this.files[0]: null;
|
2020-05-14 17:59:29 +02:00
|
|
|
if (file === null) {
|
|
|
|
return false;
|
|
|
|
}
|
2020-05-14 17:35:46 +02:00
|
|
|
|
|
|
|
// Build Form Data
|
|
|
|
var url = $('#jsform').attr("action") || window.location.href;
|
|
|
|
var form = new FormData();
|
|
|
|
form.append("tokenCSRF", $('[name="tokenCSRF"]').val());
|
|
|
|
form.append("backupFile", file);
|
|
|
|
|
|
|
|
// Apply Form
|
|
|
|
$.ajax({
|
|
|
|
url: url,
|
|
|
|
data: form,
|
|
|
|
type: "POST",
|
|
|
|
dataType: "json",
|
|
|
|
mimeType: "multipart/form-data",
|
|
|
|
contentType: false,
|
|
|
|
processData: false,
|
2020-05-14 17:59:29 +02:00
|
|
|
error: function (jqXHR, status, error) {
|
2020-05-14 17:35:46 +02:00
|
|
|
var data = jqXHR.responseJSON;
|
|
|
|
var alert = $("<div></div>").addClass("alert alert-danger").text(data.message);
|
|
|
|
|
|
|
|
$("#jsform .alert:not(.alert-primary)").remove();
|
|
|
|
$("#jstokenCSRF").after(alert);
|
|
|
|
},
|
2020-05-14 17:59:29 +02:00
|
|
|
success: function (data, status, jqXHR) {
|
2020-05-14 17:35:46 +02:00
|
|
|
window.location.reload();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|