Transferring documents using JavaScript

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?

Answer №1

If you're encountering issues, it could be related to your PHP configurations. Ensure to review both the upload_max_filesize and post_max_size settings.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips on using the $.grep() method in jQuery to filter dynamic inputs

When using the "grep" function in jQuery to filter data, the code sample below works well for static conditions. However, if the "name" and "school" parameters have multiple values, how can we filter them? Let's say I receive the name and school from ...

The naming convention for Vuex store modules involves appending to the state

Currently, I am utilizing the module approach within my Vue store. Whenever I include the imported file to the modules object, the Module state gets wrapped inside the module name. Here is an example of my auth.js file: import axios from 'axios' ...

Is there a way to switch between showing and hiding all images rather than just hiding them one by one?

Is there a way I can modify my code to create a button that toggles between hiding and showing all images (under the user_upload class), instead of just hiding them? function hidei(id) { $('.user_upload').toggle(); Any suggestions would be grea ...

Troubleshooting server-side sorting issues with AJAX implementation, encountering problems with headers functionality

I'm encountering a problem: Some headers are not functioning properly to sort the table. For example, Brand and Model work as expected, but VehicleType only works once, and CarID and ReleaseDate never seem to work. Here is my index.php file: index. ...

What is the process for including an item in an array within Firestore?

Can someone help me with this code snippet I'm working on: await firebase.firestore().doc(`documents/${documentData.id}`).update({ predictionHistory: firebase.firestore.FieldValue.arrayUnion(...[predictions]) }); The predictions variable is an ar ...

Adjusting the sound levels of an HTML audio element using JavaScript

I'm looking to adjust the volume of an <audio> element when a user clicks on an image. HTML: <div id="cloud"> <img name="jsVolumeButton" src="images/cloud.png" width = "140px"/> </div> <audio id="player" src="sounds/rain. ...

What is the best way to share both text and an image URL in a single tweet through the Twitter API

Currently, I am utilizing the Twitter API Client for node which includes both the REST and Streaming API. You can find more information about this client by visiting this link. Specifically, I am working with the twit API in conjunction with nodejs. My go ...

Using a jQuery script, you can enable a back button functionality that allows users

I created a survey to assist individuals in determining where to go based on the type of ticket they have. However, I am currently facing difficulties with implementing a "Back" button that will display the previous screen or "ul" that the user saw. Initia ...

Ways to disable an AJAX loading animation

In my current script, I am loading external content using the following code: <script type="text/javascript"> var http_request = false; function makePOSTRequest(url, parameters) { // Code for making POST request } function alertContents() { ...

Guide to configuring the initial lookAt/target for a Control

I'm looking to establish the initial 'lookAt' point for my scene, which will serve as both the center of the screen and the rotation control's focus. Ideally, I'd like to set a specific point or object position rather than rotation ...

What are the best methods for improving the rendering performance of multiple sphereGeometry objects in three.js?

Looking to improve the rendering performance of sphereGeometry in my three.js program, as it is currently a bottleneck. Here is the JavaScript code I am using: var sphereThree = []; for(var idSphere = 0; idSphere < numSphere; idSphere++){ var spher ...

Interactive PDFs that launch a new browser tab rather than automatically downloading

I am facing an issue with my web API that is returning a JSReport as an encoded byte array. Despite multiple attempts to read the byte array, I keep encountering either a black screen or an error message indicating "failed to download PDF". Interestingly, ...

Clicking on the image in an owl carousel slider does not trigger the onsen template page to load

I am experiencing an issue with my owl carousel slider while calling an API for page content on image click. I have implemented an onsen template page using ng-click on image, but it only works for the first image click. Subsequent images do not call the o ...

Tips for choosing a specific point on a Vuetify <v-slider> using Cypress

Currently, I am exploring how my application responds when a user interacts with a specific area on a basic Vuetify <v-slider>. How can I replicate this scenario in a Cypress integration test effectively? For instance, to click on the center of the ...

Column Locking with Merged Rows

I have implemented row spanning in jqgrid by following the instructions provided in this answer: Jqgrid - grouping row level data However, I am facing an issue where setting a column with row span to frozen = true causes the overlay to lose the row spanni ...

It is likely that the variable is out of scope and is undefined

I have a piece of code that retrieves the description of a word in JSON format from website, which is provided by the user in the request JSON body. The issue I'm facing is that I am unable to send back the 'desc' variable in the res.send ...

Minimize a pop-up window and navigate to a different webpage

I have created a login/logout form that includes the option to delete my account. When I click the "Sterge cont" button, a pop-up window appears asking if I truly want to delete the account. If I select "NU," the account will not be deleted and the window ...

What is the process of disabling console log in a Vue template?

Origins of the $log variable: Vue.prototype.$log = console.log Restricted Areas: <template> <!-- Restricted Area 1 --> <div @click="$log"> <!-- Restricted Area 2 --> {{ $log }} <!-- Restricted Area 3 -- ...

Using jQuery and Laravel framework to handle a POST request

Could someone assist me with troubleshooting a jQuery post request issue? I suspect there may be an error with the routes or controller. Here is my JavaScript code for the post request: $.post('http://localhost:8000/ajax', { ...

How can I accommodate pushState routes from Backbone.js on a node.js express server?

pushState feature was added to Backbone.js in version 0.5. According to the backbone documentation: When using real URLs, your web server must be capable of rendering those pages as well. For example, if you have a route like /documents/100, your web s ...