I have found some examples that explains how to make input type=file to be non editable.
like <input type="file" onkeydown="blur()" />
But I made test application in Visual Studio and find out that <input type="file" />
in non editable by default.
How to make it editable?
thanks
The only way to set the value of a file input is by the user to select a file. This is done for security reasons. Otherwise you would be able to create a JavaScript that automatically uploads a specific file from the client's computer.
The best approach would be to have a custom label element with a for attribute attached to a hidden file input element. (The label's for attribute must match the file element's id in order for this to work). In terms of styling, just hide1 the input element using the attribute selector.
The behavior of <input type="file">
elements is very strictly controlled by browsers, and you cannot force them to do anything other than what they want to do. Generally, modern browsers will only allow a file picker to be used for selecting a file for upload. Your Javascript code can't set the value and can't see anything more than the tail file name (the name without prefixing directory names).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With