madusanka
madusanka

Reputation: 163

uploading files in js

i'm using below method to upload files to 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);
                };
            },

but when i select a file larger than 5mb or around, it doesn't add the element to the relevant object of the documentArray but it logs the result in console, so i cant add validation on backend. please give me a way to solve this problem

Upvotes: 0

Views: 55

Answers (1)

Baracuda078
Baracuda078

Reputation: 687

Maybe the problem is with your PHP settings. Check your upload_max_filesize and your post_max_size

Upvotes: 1

Related Questions