Issue with uploading files on Android devices in Laravel and Vue JS

My Laravel/Vue JS web app allows users to upload files and photos. Everything runs smoothly except when accessed on Android devices, where the axios call seems to get stuck indefinitely. Below is the code snippet causing the issue:

Vue JS component

<template>
    <span>
        <v-btn @click="pickFile">
            <small>{{ label }}</small>
        </v-btn>
        <input type="file" style="
            visibility:hidden;visibility: hidden;
            position: absolute;
            width: 1px;
            height: 1px;
            left: 0;
            right: 0;"
        ref="upload" :accept="accept" @change="onFilePicked"> // accept is defined in the element's props
    </span>
</template>

Vue JS components' methods

methods: {
    pickFile() {
        this.$refs.upload.click()
    },
    onFilePicked (e) {
        const files = e.target.files
        let elem = this
        let valid = true
        Event.$emit('uploading')
        if(files[0] !== undefined) {
            elem.fileName = files[0].name
            if(elem.fileName.lastIndexOf('.') <= 0) {
                return
            }

            const fr = new FileReader ()
            fr.readAsDataURL(files[0])

            fr.addEventListener('load', () => {
                let formData = new FormData();
                formData.append('file',files[0]);
                formData.append('document',elem.document);
                formData.append('pedido',elem.pedido);

                console.log(formData)

                axios.post('/files/upload-file',formData, { headers: {'Content-Type': 'multipart/form-data'}})
                .then(response => {
                    //console.log(response);
                    Event.$emit('fileUploaded', response.data.filepath);
                    Event.$emit('alert', 'Your file has been successfully saved');
                });
            });
        } else {
            elem.fileName = ''
        }
    }
},

On the server side, I utilize the Input, Storage and File facades for disk writing, and store a FileEntry in my database. While this function operates flawlessly on computers and iOS devices, it encounters an issue on Android devices. Could there be any specific considerations for Android that I've overlooked?

Answer №1

After investigating further, I discovered that the issue was not related to Android devices but rather the size of the upload file. I have now adjusted the necessary php.ini settings and will start compressing images in real-time.

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

Create a package that is compatible with both node and browser environments

After successfully creating a node NPM package that acts as a wrapper for a specific JSON API using node's http, https, and querystring modules, I am now looking to expand its usability by making it compatible with browsers. This would involve replaci ...

Sending a massive video file to a node.js server and saving it in AWS S3 with ReactJS

I am currently in the process of creating an OTT platform, but I have encountered a problem while attempting to upload large files to the server. I initially attempted to store the file in a temporary folder using multer and then utilize aws-sdk s3.upload. ...

Advantages of using index.js within a component directory

It seems to be a common practice to have an index file in the component/container/module folders of react or angular2 projects. Examples of this can be seen in: angular2-webpack-starter react-boilerplate What advantages does this bring? When is it recom ...

React app experiencing issues with onClick button methods not functioning as expected

Here is the React code for a sample homepage. My intention was to have the function run and update the page when the buttons are clicked. However, instead of updating the page, it keeps showing alerts. I have confirmed that the fetch function is pulling da ...

Utilizing external libraries with RiotJS for greater functionality

My jQuery flexslider is causing slide animation issues because the library is being loaded before the DOM. As a result, I can't trigger actions of the flexslider. Here's the HTML structure: <html> <body> <home-templat ...

Exploring Laravel 8 Eloquent Relationships: A Deep Dive into Querying with

I am trying to showcase products with at least one image, using one of the images as the card cover. However, my current query is generating multiple cards for each image in the database. Models class Product extends Model { public function getAllData ...

Visualizing Dynamic Path on VueJS Using Polygon Map

I am facing some issues with implementing Google Maps in Vue.js. I have created a polygon component as shown below: <script> export default { name: "MapPolygon", props: { google: { type: Object, ...

"Implementing ASP.NET MVC4 with Razor: Dynamically filtering a dropdown list based on the selected value from another dropdown

Currently, I am facing a challenge where I need to filter the options of a dropdown list based on the value selected from another dropdown. Within my database, there are tables containing all countries and all cities in the world, with a foreign key linkin ...

The router link is unable to redirect to the desired page

neither the static router nor the dynamic router can navigate to the page. Here is the HTML code: <router-link to="/add_peer">Test</router-link> <router-link :to="{path:'/add_peer'}">Test</router-link> ...

In search of a tool that enables horizontal scrolling of content

I am on the lookout for a piece of Javascript code that can be integrated into my website to enable me to horizontally scroll content either from left to right or right to left. Although I found this script here: It offers the fundamental functionality th ...

Encountering a "connection refused" error while attempting to access a php page located on localhost via an android application

I'm currently working on my first demo app that involves communicating with a remote server. I have set up a PHP project on my localhost and I'm attempting to access a PHP page from an Android app. However, when I try to run and access the page, ...

Can you tell me about some commonly used GUI widgets in Servlet-JSP?

I am new to working with Servlets, Tomcat, JSP, and I am curious about the common practices for incorporating GUI elements into JSP pages to enhance client-side interactivity. I have experience with jQuery, YUI, extJS, among others, for JavaScript scriptin ...

Concealing specific DIV elements (unfortunately not nested)

Currently, I am dealing with pre-existing code that is automatically generated and needs to adhere to a specific format: <div id="TITLE1"></div> <div id="div-1"></div> <div id="div-2"></div> <div id="div-3"></d ...

Difficulty with Implementing Swipe Animation for RecyclerView Item

Currently, I am developing an Android app that includes RecyclerView and swipe-to-dismiss functionality. During the process of implementing the swipe-to-show-options animation, I encountered a unique problem. Below is the code snippet for my custom swipe- ...

Angular - automated pagination functionality without requiring user input

I apologize for the poorly worded title. Context In my static display angular app, I am not incorporating any user interactions and most actions are time-based. The page loads, and after a specific amount of time determined by certain elements, it reload ...

Tips for adjusting the placeholder color in Material UI using React JS

Is there a way to customize the background color and flashing color of the Skeleton component in Material UI? I would like to implement custom styling for it, similar to what is shown below: <Skeleton variant="circle" classes={{root:'pla ...

Support for Vue 3.4 same-name shorthand has been added to VS Code

After upgrading my Vue 3 project to version 3.4, I encountered an issue with vs-code highlighting same-name shorthand as an error, even though it was functioning correctly in my code. I am using the volar extension. Is there a way to resolve this so that v ...

Exploring the world of JSON files using JavaScript

Basically, my bot responds to a command (!accounts) by providing users with information based on their ID. For example, if an ID of 662 sends the command !account, the bot will search for steamID 662 in the json files and display the currency and correspon ...

The replacement of className in inline SVG is not permitted (Error: 'Cannot read property 'className.replace' of undefined')

I've hit a roadblock trying to manipulate classes within an SVG document to modify the rect elements. The code works smoothly on divs in an external document, but I've tried several other solutions as well – all listed below. I'm still rel ...

Utilize prop-types inheritance when a component is rendered via props

Is it possible to inherit prop-types when a component is rendered via the parents prop, without direct access to 'ChildProps' and 'Props' interface? Parent Component interface ChildProps { counter: number; setCounter: React.Dispat ...