Jak uzyskać nazwę pliku z typu wejściowego = element html pliku za pomocą JavaScript lub JQuery?
W przeglądarce Google Chrome próbowałem kilku sposobów, a kolejne i żadna nie podaje mi wartości dołączonej nazwy pliku, po zatwierdzeniu prześlę plik. Ale zawsze jego undefined lub val () nie znaleziono ..
Jak to rozwiązać?
console.log($("input[name='attachment[]']"));
/* Output:
[
<input type="file" name="attachment[]" id="attachment">
,
<input type="file" name="attachment[]" id="attachment">
,
<input type="file" name="attachment[]" id="attachment">
]
*/
$.each($("input[name='attachment[]']"), function(i,v) {
console.log(i);
console.log(v); //v.val() does not exist... even uploaded a file and showing file
});
/* Output:
0
<input type="file" name="attachment[]" id="attachment">
1
<input type="file" name="attachment[]" id="attachment">
2
<input type="file" name="attachment[]" id="attachment">
*/
return false;