Quasar Framework Uploader with axios

前端 未结 1 901
情话喂你
情话喂你 2021-01-16 04:44

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

I\'m usin

相关标签:
1条回答
  • 2021-01-16 05:40

    I have successfully done uploading of the file to python API.


    V1 Update

    Use @added -> function(files) method.


    This is the component:

    <q-uploader
              url=""
              extensions=".gif,.jpg,.jpeg,.png"
              @add="file_selected"
              />
    
    <q-btn @click="uploadFile()">Upload</q-btn>
    

    Data:

    data() {
      return {
        selected_file:'',
        check_if_document_upload:false
      }
    }
    

    Methods

    file_selected(file) {
            this.selected_file = file[0];
            this.check_if_document_upload=true
          },
    
    uploadFile(){
            let fd = new FormData();
            fd.append("file", this.selected_file);
    
            axios.post('/uploadFile',fd,{
              headers: { 'Content-Type': undefined},
            }).then(function (response) {
              if (response.data.ok) {
              }
            }.bind(this));
    
          }
    

    This is working fine for me.

    0 讨论(0)
提交回复
热议问题