No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Unable to upload image from Cordova to web server - No idea why

    Help
    1
    1
    99
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      bambinou last edited by bambinou

      Hi All.

      I have installed Quasar and Cordova, I am totally unable to upload an image to my webserver.

      Here is my code:

      sendReport: function () {
            let formData = new FormData();
            formData.append('type', this.type);
            formData.append('siteimage', this.picturePath);
      
            api.post('/addreport', formData, { headers: { 'content-type': 'multipart/form-data' } })
              .then((response) => {
      
      
                this.$store.dispatch('alerts/alertGreen', 'Your report has been sent', {
                  root: true
                });
              })
              .catch(error => {
                if (error.response.status < 500) {
                  this.$store.dispatch('alerts/alertRed', 'There is a problem, please tryin again', {
                    root: true
                  });
                } else {
                  this.$store.dispatch('alerts/alertRed', 'There is something wrong with our server, please try again later', {
                    root: true
                  });
                }
              });
      

      In the chrome console, I get everything sent properly as:

      type: land
      siteimage: file:///storage/emulated/0/Android/data/com.ken.mobile/cache/1560461815392.jpg
      

      On the web server side(Laravel), I get:

      {"siteimage":["The siteimage must be an image.","The siteimage must be a file of type: jpeg, png, jpg."]}
      

      It is like my server script does not recognise this image. Is this something to do with Cordova itself?

      I saw a lot of people using a file transfer plugin(which is now deprecated), is there a way to do the exact same thing with Axios or is it not possible?

      Thank you

      1 Reply Last reply Reply Quote 0
      • First post
        Last post