Ignite UI for Web Components 파일 입력 구성 요소는 사용자가 파일을 선택하고 업로드할 수 있는 대화형 방법을 제공합니다. 파일 선택과 같은 파일별 기능을 추가하고, 선택한 파일 이름을 표시하고, 여러 파일 업로드를 지원하여 기본 IgcInputComponent 기능을 확장합니다.
<!DOCTYPE html><html><head><title>File Input Overview</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v5.css"type="text/css" /></head><body><divid="root"><divclass="container sample center"><igc-file-inputlabel="File input"></igc-file-input></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
Like this sample? Get access to our complete Ignite UI for Web Components toolkit and start building your own apps in minutes. Download it for free.
Usage
The IgcFileInputComponent component allows users to select files from their device and upload them to a web application. It displays the names of selected files and offers customization options for the browse button and the "No file chosen" text. The component also provides properties, methods, and slots that can be used to further configure its behavior to suit your needs.
시작하기
To start using the IgcFileInputComponent, first, you need to install the Ignite UI for Web Components by running the following command:
Ignite UI for Web Components에 대한 전체 소개를 보려면 시작하기 항목을 읽어보세요.
구성
Properties
The IgcFileInputComponent component offers a variety of properties that allow you to configure its behavior based on specific requirements. These properties give you control over the input’s functionality, appearance, and validation.
value - Sets the current value of the file input field.
disabled - Disables the file input, preventing user interaction.
required - Marks the input as mandatory. Form submission will be blocked unless a file is selected.
invalid - Indicates that the input value is invalid, used to trigger visual error states.
multiple - Allows the selection of multiple files.
accept - Defines the types of files that can be selected. The value for this property needs to be a comma-separated list of file formats (e.g., .jpg, .png, .gif).
autofocus - Automatically focuses the file input field when the page loads.
label - Sets the label text associated with the file input element.
placeholder - Provides placeholder text displayed when no file is selected.
In addition to its configurable properties, there are four useful methods inherited from the IgcInputComponent component that you can use in the IgcFileInputComponent component:
<!DOCTYPE html><html><head><title>File Input Prefix & Suffix</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v5.css"type="text/css" /></head><body><divid="root"><divclass="container sample center"><igc-file-inputlabel="Input with slots"><igc-iconname="imageIcon"slot="prefix"></igc-icon><igc-iconname="uploadFile"slot="suffix"></igc-icon><spanslot="helper-text">Sample helper text.</span><spanslot="file-selector-text">Upload</span><spanslot="value-missing">Please upload file</span></igc-file-input></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
Integration
The IgcFileInputComponent component integrates seamlessly with the HTML Form element. Using the methods and properties described above, you can effectively manage its behavior and validation within the standard HTML Forms.
<!DOCTYPE html><html><head><title>File Input in Form</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png"><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v5.css"type="text/css" /></head><body><divid="root"><divclass="container sample center"><formid='form1'enctype="multipart/form-data"><fieldset><igc-file-inputid="fInput"name="fInput"label="Required field"multiplerequired><pslot="helper-text">You can upload any type of file.</p><pslot="value-missing">You must upload a file</p></igc-file-input><igc-buttonvariant="outlined"type="submit">Submit</igc-button><igc-buttonvariant="outlined"type="reset">Reset</igc-button></fieldset></form></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %>
<scriptsrc="src/index.ts"></script>
<% } %>
</body></html>html
"찾아보기" 단추 및 "선택한 파일 없음" 메시지의 기본 문자열은 자동으로 지역화되지 않습니다. 이러한 문자열은 모든 로케일에서 동일하게 유지되지만 적절한 슬롯 또는 플레이스홀더 바인딩을 사용하여 수동으로 사용자 지정할 수 있습니다.
속성을 통해 파일을 수동으로 설정할 수 없습니다 value. 파일 선택은 파일 선택기를 통해서만 수행할 수 있습니다. 그러나 빈 문자열을'' 전달하여 필드를 재설정할 수 있습니다.
Accessibility & ARIA Support
The IgcFileInputComponent component is both focusable and interactive, ensuring full keyboard and screen reader accessibility. The component can be labeled using the label attribute, which leverages the native <label> element to provide a semantically correct and accessible label.
접근성 권장사항을 지원하기 위해 구성요소는 관련 ARIA 속성도 적용합니다.
aria-invalid- 입력이 잘못된 상태인 경우 "true"로 설정합니다.
aria-describedby- 도우미 텍스트 요소가 있는 경우 자동으로 연결되어 보조 기술이 추가 정보를 알릴 수 있습니다.
Styling
The IgcFileInputComponent component exposes CSS parts which we can use for styling. The following table lists all of the exposed CSS parts:
<!DOCTYPE html><html><head><title>File Input Styling</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v5.css"type="text/css" /></head><body><divid="root"><divclass="container sample center"><igc-file-inputlabel="Input styling"><igc-iconname="uploadFile"slot="suffix"></igc-icon></igc-file-input></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html