Brak nazwy pliku w input "file"

0

W default jak wybiorę plik to obok wyświetlona jest nazwa. Jak kliknę button i nic nie wybiorę to nazwa resetuje się.

W custom jak wybiorę plik to nie widać nazwy pliku a chciałem żeby było jak w default czyli nazwa obok a jak nie wybiorę pliku to nic.

<h1>default</h1>
<label for="default">default</label>
<input type="file" name="default">

<h1>custom</h1>
<label for="custom" class="custom-file-upload">custom</label>
<input type="file" name="custom" id="custom" class="custom-input">

.custom-input {
    display: none;
}

.custom-file-upload {
    border: 1px solid #ccc;
    display: inline-block;
    padding: 6px 12px;
    cursor: pointer;
}

demo http://jsfiddle.net/96q8awvk/10/

0

Sprawdź kod:

<label for="custom" id="filename" class="custom-file-upload">custom</label>
<input type="file" onchange="document.getElementById('filename').innerHTML=this.value;" name="custom" id="custom" class="custom-input">

1 użytkowników online, w tym zalogowanych: 0, gości: 1