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

    File / directory select?

    Help
    2
    3
    2696
    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.
    • Z
      Zyme last edited by Zyme

      I am using quasar with webpack and I want the user to select a file or a directory locally and then save that path to the app settings.

      I can only find the Uploader component, but I don’t want to upload anything, since it already exists on disk.

      Is there an easy way to trigger the file selection component? Maybe with a QBtn?

      I see the <q-input> supports type=“file” but it looks terrible. The button is not styled etc.

      1 Reply Last reply Reply Quote 0
      • Z
        Zyme last edited by Zyme

        Figured it out:

        <template>
          <main>
            <q-field helper="Path to data store">
            
              <q-input clearable v-model="settings.data_path" stack-label="Data storage" />
              
              <input type="file" id="dataPath" v-on:change="setDataPath" ref="fileInput" hidden />
        
            </q-field>
            <q-btn color="primary" v-on:click="selectPath">Set data path</q-btn>
          </main>
        </template>
        

        …

        methods: {
              selectPath () {
                console.log('Selecting path for data store')
        
                this.$refs.fileInput.click()
              },
        
              setDataPath (file) {
                this.settings.data_path = file.target.files[0].path
              }
            }
        
        1 Reply Last reply Reply Quote 2
        • F
          flight9 last edited by

          I’m finding this. Thanks a lot. @Zyme

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