HTML DOM Input FileUpload Object
Đầu vào đối tượng tải lên tệp
Đối tượng Input FileUpload đại diện cho một phần tử HTML <input> với type = "file".
Truy cập một đối tượng tải tệp đầu vào
Bạn có thể truy cập phần tử <input> với type = "file" bằng cách sử dụng getElementById ():
Thí dụ
var x = document.getElementById("myFile");
Mẹo: Bạn cũng có thể truy cập <input type = "file"> bằng cách tìm kiếm qua bộ sưu tập phần tử của biểu mẫu.
Tạo đối tượng tải tệp đầu vào
Bạn có thể tạo phần tử <input> với type = "file" bằng cách sử dụng phương thức document.createElement ():
Thí dụ
var x = document.createElement("INPUT");
x.setAttribute("type", "file");
Đầu vào Tệp Tải xuống Thuộc tính Đối tượng
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 |
Thuộc tính và sự kiện tiêu chuẩn
Đối tượng Input FileUpload cũng hỗ trợ các thuộc tính và sự kiện tiêu chuẩn .
Các trang liên quan
Hướng dẫn HTML: Biểu mẫu HTML
Tham chiếu HTML: Thẻ HTML <input>
Tham chiếu HTML: Thuộc tính loại HTML <input>