#Showing file input dialog without direct `input` interaction

1 messages · Page 1 of 1 (latest)

ivory solstice
#

Hello, is there any way for me to prompt the user to pick a file from the system dialog without them directly clicking on a input { r#type="file" } component?
I want an async channel to be able to request for a file and then know if it got one (or if the dialog was cancelled).

I've thought about perhaps having a hidden file input component, but I'm not sure how I can simulate clicking it to show the dialog.
Even still, it seems that the cancel event is not supported, so I will be waiting indefinitely if the user cancels the file picker dialog.

I have read Handling files.

Does anyone have any suggestions?
Thank you

MDN Web Docs

The cancel event fires on an <input> element when the user cancels the file picker dialog via the Esc key or the cancel button and when the user re-selects the same files that were previously selected of type="file".

A fullstack crossplatform app framework for Rust. Supports Web, Desktop, SSR, Liveview, and Mobile.

strange canopy
#

If you are targeting desktop, the rfd crate works well. It is what dioxus uses to intercept file dialog events: https://docs.rs/rfd/latest/rfd/