如何使用vue-dropzone通过axios上传图像?

时间:2020-09-14 03:39:29

标签: javascript file-upload vuejs2 axios dropzone

我正在尝试使用vue-dropzone将图像上传到数据库,后端开发人员提供的上传API示例如下:

export const actions = {
  uploadGallery (ctx, file) {
    return new Promise((resolve, reject) => {
      this.$axios.$post('galleries/upload', file)
        .then(resolve)
        .catch(reject)
    })
  }
}

我的dropzone选项如下:

  dropzoneOptions: {
    url: 'galleries/upload',
    thumbnailWidth: 175,
    thumbnailHeight: 150,
    maxFilesize: 1,
    addRemoveLinks: true
  }

我只是将请求URL放在dropzone选项中,但不能正常工作。 有人可以告诉我如何整合dropzone和Axios吗? (还要保留进度条功能,我可以将autoProcessQueue设置为false,并使用外部方法上传图像,但是如果这样做,进度条将不会更新)

感谢您的帮助!

0 个答案:

没有答案