alexusmai / vue-laravel-file-manager

Frontend for Laravel File Manager on Vue.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use as file selector

bajki opened this issue · comments

commented

Hi, is it posible to make this as file selector that returns file path on select like asgardcms has media manager.

https://github.com/Idavoll/Media/blob/3.0/Assets/js/components/SingleMedia.vue
https://github.com/Idavoll/Media/blob/3.0/Assets/js/components/MultipleMedia.vue

Thanks

Hi @bajki,

I've just tried to achieve the same in one of the projects I have been working on and the answer is to use Vuex store. I've done it as below:

computed: {
  fileSelected() {
    return this.$store.state.fm.left.selected.files;
  }
},
watch: {
  fileSelected() {
    if (this.fileSelected.length > 0) {
      this.modelValue.url = `/storage/${this.fileSelected[0]}`;
      this.isFilemanagerOpen = false;
    }
  }
}

This way, as soon as some file is selected, I'm getting the file path (and I also close the file manager that I open initially in the modal).

Hope that helps!

Best,
Bartek.