Accessing a file path from an HTML input in Tauri

75 Views Asked by At

I have an app that I'm converting from Electron to Tauri. It's pretty plain, just an HTML file with some client side JS in it. One of the things that it does is when you click a button, it opens a file dialog, and it saves the path of that file.

In Electron, it exposes the path, but Tauri doesn't seem to. Any tips on how I can get that file path in the JS?

My HTML:

<input type="file" accept=".pdf" id="file" />

My JS:

document.getElementById("file").addEventListener("change", () => {
    pathUrl = document.getElementById("file").files[0].path;
    savePath();
});

Again, this works just fine in Electron, but I'm not sure how to Tauri-ify this.

I added the dialog thing to the allowlist:

"dialog": {
  "open": true
}

But I'm not sure if I'm on the right track!

0

There are 0 best solutions below