[Vuejs]-How I can upload files using Laravue with Dropzone

0๐Ÿ‘

โœ…

I figured out how to upload files with dropzone, en the method handleUpload I just have to send the file to a post method in laravel backend who upload a temporary file

dropzoneR(file) {
  var name = file.upload.filename;
  fileResource.borrar(name).then(response => {
    this.files.splice(this.files.indexOf(name), 1);
    if (this.files.length < 1) {
      this.btnUpload = true;
    }
  }).catch(error => {
    console.log(error);
  });
},

and returns an ok if it gets uploaded, then when I confirm thats the files I need up, other method in laravel backend who do what a want to do with the file if its an excel file (in mi case) upload the data to the database, or what ever I want. like this

async handleUpload(e) {
  this.weblogCreating = true;
  await bitacoraResource.store(this.files).then(response => {
    this.$message({ message: 'Bitacoras importadas satisfactoriamente', type: 'success' });
    this.files = '';
    this.dialogImportVisible = false;
    this.weblogCreating = false;
    this.getList();
  }).catch(error => {
    this.$message({
      message: 'Error importando las bitacoras ' + error.getMessage,
      type: 'error',
    });
    this.weblogCreating = false;
    console.log(error.message);
  });
},

Leave a comment