Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make <input type="file" /> editable?

Tags:

html

file

input

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

like image 883
eomeroff Avatar asked Nov 26 '10 16:11

eomeroff


People also ask

How do I change the default value of an input type file?

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.

How do I customize the Choose file button in HTML?

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.


1 Answers

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).

like image 56
Pointy Avatar answered Sep 27 '22 19:09

Pointy