Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Nazwa pliku z input, jak wyciągnąć nazwę pliku bez ścieżki ?
Kropek_2006
post
Post #1





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 22.03.2005

Ostrzeżenie: (0%)
-----


Hej,
jak wyciągnąć nazwę pliku bez ścieżki z pola "input file" w JavaScript ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 3)
revyag
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 2 258
Pomógł: 16
Dołączył: 21.09.2004
Skąd: Kielce

Ostrzeżenie: (0%)
-----


Kod
function show_name(){
    f=document.getElementById("fil").value;
    off=f.length - f.lastIndexOf("\\");
    return f.substr(f.lastIndexOf("\\")+1,off);
}

funkcja zwraca nazwę pliku.
Go to the top of the page
+Quote Post
berdyk
post
Post #3





Grupa: Zarejestrowani
Postów: 41
Pomógł: 0
Dołączył: 30.05.2003

Ostrzeżenie: (0%)
-----


a jak byłoby z wyciągnięciem rozszezenia pliku
i co to jest fil w getElementById
Go to the top of the page
+Quote Post
revyag
post
Post #4





Grupa: Przyjaciele php.pl
Postów: 2 258
Pomógł: 16
Dołączył: 21.09.2004
Skąd: Kielce

Ostrzeżenie: (0%)
-----


Kod
<script type="text/javascript">
function show_name(){
    f=document.getElementById("fil").value;
    off=f.length - f.lastIndexOf(".");
    return f.substr(f.lastIndexOf(".")+1,off);
}
</script>

  1. <input id="fil" type="file" value="">
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 18:55