PHPDesktop: Naming of form fields

72 views
Skip to first unread message

Heinz Ernst

unread,
Dec 30, 2024, 11:52:06 AM12/30/24
to PHP Desktop
Does anyone know how I can change the name of the form field “choose file” to “Durchsuchen” in an upload form (type=“file”)? My application is intended for users with German language. Thank you for helping.
Kind regards,
Heinz

Terry J

unread,
Dec 31, 2024, 8:19:46 AM12/31/24
to PHP Desktop
Few ways to approach:

1) Make sure web page is set to German:

Terry J

unread,
Jan 1, 2025, 12:46:09 PMJan 1
to PHP Desktop
Got the email but do not see the update here and filename, very odd indeed.

Try this one to get file name: https://jsfiddle.net/0x9sn43j/

Heinz Ernst

unread,
Jan 1, 2025, 1:12:46 PMJan 1
to PHP Desktop
Hi Terry,
first I wish you and all of the members of the group a Happy New Year. I am so grateful to receive help from this group. This is my code I used, but next to the form field “Choose file”, or in German “Durchsuchen”, a note normally appears directly next to the form field “Choose file” that no file has yet been selected (“no file chosen”). Once the file has been selected, the name of the file appears next to the “Choose file” form field. Is it possible to adapt the form and the JavaScript accordingly? Here is the code:

        <form action="generate_invoices.php" method="post" enctype="multipart/form-data">
          <label for="excelFile">Wähle eine Excel-Datei:</label>
          <input type="file" name="excelFile" id="excelFile" style="display:none;" accept=".xlsx, .xls">
<button type="button" id="upload-button">Durchsuchen</button>
          <input type="submit" value="Hochladen und Verarbeiten">
      </form>

<script>
document.getElementById('upload-button').addEventListener('click', function() {
document.getElementById('excelFile').click();
});
</script>
Thanks a lot for helping.
Heinz

Heinz Ernst

unread,
Jan 1, 2025, 1:31:31 PMJan 1
to PHP Desktop
I forgot to attach the corresponding screenshot. Here it comes
Screenshot 2025-01-01 192818.jpg

Terry J

unread,
Jan 1, 2025, 2:05:07 PMJan 1
to PHP Desktop
Hello Heinz and Happy New Year! I will attempt to assist you.

Really hard to forces word using plain html form as each browser seems to control those function.

JavaScript is what I would normally use, hope it can help you. Try this:

https://jsfiddle.net/g7qewdam/

Heinz Ernst

unread,
Jan 1, 2025, 2:32:35 PMJan 1
to PHP Desktop
Great, it works. Many, many thanks.
Heinz

Terry J

unread,
Jan 1, 2025, 2:52:02 PMJan 1
to PHP Desktop
Your most welcome Heinz.

Khalfan Mohamed

unread,
Jan 15, 2025, 10:59:10 AMJan 15
to PHP Desktop

Here's how you can answer Heinz's question:


Hi Heinz,

You cannot directly change the text of the "Choose File" button in an <input type="file"> element because it's part of the browser's native styling. However, you can achieve this by hiding the default file input and creating a custom label/button with the desired text.

Terry J

unread,
Jan 16, 2025, 10:30:07 AMJan 16
to PHP Desktop
@Khalfan: " However, you can achieve this by hiding the default file input and creating a custom label/button with the desired text.  "

Got a real-life code example to share with us?
Reply all
Reply to author
Forward
0 new messages