HTML-DOM -Eingabe-FileUpload- Objekt
Geben Sie das FileUpload-Objekt ein
Das Input FileUpload-Objekt repräsentiert ein HTML-<input>-Element mit type="file".
Greifen Sie auf ein FileUpload-Eingabeobjekt zu
Sie können auf ein <input>-Element mit type="file" zugreifen, indem Sie getElementById() verwenden:
Beispiel
var x = document.getElementById("myFile");
Tipp: Sie können auch auf <input type="file"> zugreifen, indem Sie die Elementsammlung eines Formulars durchsuchen .
Erstellen Sie ein FileUpload-Eingabeobjekt
Sie können ein <input>-Element mit type="file" erstellen, indem Sie die Methode document.createElement() verwenden:
Beispiel
var x = document.createElement("INPUT");
x.setAttribute("type", "file");
Geben Sie die FileUpload-Objekteigenschaften ein
Property | Description |
---|---|
accept | Sets or returns the value of the accept attribute of the file upload button |
autofocus | Sets or returns whether a file upload button should automatically get focus upon page load |
defaultValue | Sets or returns the default value of the file upload button |
disabled | Sets or returns whether the file upload button is disabled, or not |
files | Returns a FileList object that represents the file or files selected with the file upload button |
form | Returns a reference to the form that contains the file upload button |
multiple | Sets or returns whether a user is allowed to select more than one file in the file upload field |
name | Sets or returns the value of the name attribute of the file upload button |
required | Sets or returns whether a file in the file upload field must be selected before submitting a form |
type | Returns which type of form element the file upload button is |
value | Returns the path or the name of the selected file |
Standardeigenschaften und -ereignisse
Das Input FileUpload - Objekt unterstützt auch die Standardeigenschaften und - ereignisse .
Verwandte Seiten
HTML-Tutorial: HTML-Formulare
HTML-Referenz: HTML-<input>-Tag
HTML-Referenz: HTML-Attribut vom Typ <input>