Input field in the Enter text field

I don’t even know if this is possible or not, but is there a method that you can take the value of the selected file into the file input field for the text input field?

Like this:

alt text

+3
source share
3 answers

Hook the event changeinto the file field.

<form method="post" enctype="multipart/form-data">
    <input type="file" onchange="this.form.filename.value = this.value">
    <input type="text" name="filename">
</form>

Jsfiddle demo . Please note that IE6 / 7 incorrectly sets the full path, while other browsers correctly give only the file name.

+5
source

, .value .

, , value . .

: MSDN IE8

+1

.

. , POST.

If you are after the file path, you also cannot do this (in modern browsers, as Pekka says). The browser does not provide this information to client scripts. However, it can provide a file name.

0
source

Source: https://habr.com/ru/post/1764579/


All Articles