I'm trying to get HTML file upload control working on WASM. So far I've tried to do the following:
[HtmlElement("input")]
public class FilePickerView : FrameworkElement
{
public FilePickerView()
{
// XAML behavior: a non-null background is required on an element to be "visible to pointers".
// Uno reproduces this behavior, so we must set it here even if we're not using the background.
// Not doing this will lead to a `pointer-events: none` CSS style on the control.
Background = new SolidColorBrush(Colors.Transparent);
this.SetHtmlAttribute("type", "file");
}
}
And then in the view:
<wasm:FilePickerView Height="35" Width="300" x:Name="filePicker" HorizontalAlignment="Left" />
I get the control displayed, I can click on it and it displays the name of the file I've selected.
I am pretty lost after this.
I'd like to be able to do two things:
- Access file path in code behind.
- Send file contents to code behind for processing.
Would appreciate any pointers on this.
I've been through the following pages in the documentation:
- (Wasm) Handling custom HTML events - https://qa.website.platform.uno/docs/articles/wasm-custom-events.html
- Embedding Existing JavaScript Components Into Uno-WASM - Part 1 - https://qa.website.platform.uno/docs/articles/interop/wasm-javascript-1.html
- Embedding Existing JavaScript Components Into Uno-WASM - Part 2 - https://qa.website.platform.uno/docs/articles/interop/wasm-javascript-2.html
- Embedding Existing JavaScript Components Into Uno-WASM - Part 3 - https://qa.website.platform.uno/docs/articles/interop/wasm-javascript-3.html