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

    Uploader problems. How to send the uploader file

    Help
    2
    2
    929
    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.
    • F
      fatdogv last edited by

      Hi,
      A question about the uploader.
      I need to post the images to a URL that will rename the uploaded file and return the full path.

      I’m using upload-factory and axios

      But I’m having problems understanding exactly how to pass the file to axios as if it was a input type file.
      Basically I need to make it as If I’m sending a form with a single input file like this:

      <input type="file" name="banner">
      

      This is the component:

      <q-uploader
              url=""
              extensions=".gif,.jpg,.jpeg,.png"
              :filter="filterFiles"
              :upload-factory="uploadFile"
      

      This is the upload method, but I keep getting an error.

      uploadFile (file, updateProgress) {
            const formData = new FormData()
            formData .set('banner', file)
            var headers = {
              'Content-Type': 'multipart/form-data'
            }
            axios.post('http://someurl/uploadFile', formData , headers)
              .then(function (response) {
                console.log(response)
              })
              .catch(function (response) {
                console.log(response)
              })
          }
      

      If I post a plain html form with method=“post” enctype=“multipart/form-data” and a

      <input type="file" name="banner">
      

      I get my OK response from the server with the processed/uploaded image URL

      1 Reply Last reply Reply Quote 0
      • N
        Naman last edited by

        It shows that no URl is specified in the console logs

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