
har.blade.php
Код: Выделить всё
Upload HAR File
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #f0f0f0;
}
h2 {
margin-bottom: 20px;
}
.dropzone {
width: 50%;
border: 2px dashed #007bff;
background-color: white;
padding: 20px;
border-radius: 10px;
}
.dz-message {
color: #007bff;
}
.dz-error-message {
color: red;
}
Upload HAR File
@csrf
Drop HAR file here or click to upload.
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone("#har-dropzone", {
url: "{{ route('har.upload') }}",
paramName: "file",
maxFiles: 1,
acceptedFiles: ".har",
headers: {
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
},
init: function() {
this.on("success", function(file, response) {
window.location.href = response.redirect_url;
});
this.on("error", function(file, message) {
if (!file.type.includes("har")) {
var errorMessage = document.createElement('div');
errorMessage.className = 'dz-error-message';
errorMessage.innerText = 'Invalid file type. Only HAR files are accepted.';
file.previewElement.appendChild(errorMessage);
setTimeout(function() {
location.reload();
}, 2000);
}
});
this.on("maxfilesexceeded", function(file) {
this.removeAllFiles();
this.addFile(file);
});
}
});
document.body.ondrop = function(e) {
e.preventDefault();
e.stopPropagation();
var files = e.dataTransfer.files;
if (files.length > 0 && files[0].type.includes("har")) {
myDropzone.addFile(files[0]);
} else {
alert('Invalid file type. Only HAR files are accepted.');
setTimeout(function() {
location.reload();
}, 2000);
}
};
document.body.ondragover = function(e) {
e.preventDefault();
e.stopPropagation();
};
Код: Выделить всё
Подробнее здесь: [url]https://stackoverflow.com/questions/78693322/working-locally-but-failing-on-production-with-422-unprocessable-entity-error[/url]