w3c / FileAPI

File API
https://w3c.github.io/FileAPI/
Other
104 stars 44 forks source link

file selection dialog callable by file api #56

Closed RenRoe closed 4 years ago

RenRoe commented 7 years ago

It seems, that file select dialog called by INPUT tag with type "file" is not working, because in current browser solutions this functionality cannot be invoked by code properly. The current default behaviour of this tag type is secured by explicit user clicking.

I would appreciate to get file select functions in this api, maybe a fileselect object to set all properties of fileselect dialog (type open/save, filename, mimes, flags (multiselect/single select) and so on and a show function.

chaals commented 7 years ago

@RenRoe do you mean that you would like to be able to invoke the function without an explicit user click?

I think that is unlikely to be implemented for an open web environment. People cite security concerns as the reason not to do it.

RenRoe commented 7 years ago

1) If you have a look here you will find many developers struggling with it. 2) If you allow a file api in browsers changing files locally, your argumentation fails, I believe. File selection dialog is a comfort functionality for end users. If someone will make code to compromise end users computer the file api itself is an open goal

annevk commented 7 years ago

What current browsers?

var x = document.createElement("input")
x.type = "file"
x.click()

works in Firefox.

RenRoe commented 7 years ago

That is not completely true. You can simulate the click only when the JScript x.click() comes from code initially invoked by user click (Event). I'm writing HTML5 code with WebSocket Support, where server should invoke browser to open file Dialog. But that's not working, because no user clicks. Annevks solution fails here. It also Fails in load Event of page, I guess. But I have not tested completely. I do not know what happens if click() is called with setTimeout function or other stuff which is not raised by user click.

RenRoe commented 7 years ago

I'm not sure about some additional flags and properties in annevks solution:

1) how to give file select dialog a title 2) how to modify selection mode (single file only, multiple files) 3) how to set mime types (i.e. .txt; .xlsx) 4) enable/disable Network pathes ....

annevk commented 4 years ago

Requiring user activation is a feature and seems unlikely to be removed. The remainder are features of the input element or could be features thereof. I'm going to close this request therefore.