I have been using the following method to upload files to my Laravel backend:
setFile(id, e) {
let self = this;
let reader = new FileReader();
reader.readAsDataURL(e.target.files[0]);
reader.onload = function () {
console.log(reader.result);
self.documentArray.forEach(function (element) {
if (id == element.id && reader.result) {
element.file = reader.result;
element.file_browse_name = e.target.files[0].name;
}
});
};
reader.onerror = function (error) {
console.log('Error: ', error);
};
},
However, I am facing an issue where selecting a file larger than 5mb does not add the element to the relevant object in documentArray, even though it logs the result in the console. This prevents me from adding validation on the backend. Can anyone provide a solution to overcome this problem?