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
파일 입력 구성 요소를 사용하면 사용자가 장치에서 파일을 선택하여 웹 애플리케이션에 업로드할 수 있습니다. 선택한 파일의 이름을 표시하고 찾아보기 버튼과 "선택한 파일 없음" 텍스트에 대한 사용자 지정 옵션을 제공합니다. 또한 구성 요소는 필요에 맞게 동작을 추가로 구성하는 데 사용할 수 있는 속성, 메서드 및 슬롯을 제공합니다.
시작하기
파일 입력 사용을 시작하려면 먼저 다음 명령을 실행하여 Ignite UI for Web Components 설치해야 합니다.
<!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
파일 입력 구성 요소는 HTML 양식 요소와 원활하게 통합됩니다. 위에서 설명한 메서드와 속성을 사용하면 표준 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
File Input 구성 요소는 포커스를 받을 수 있고 대화형이므로 완전한 키보드 및 화면 판독기 접근성을 보장합니다. 구성 요소는 속성을 사용하여 label 레이블을 지정할 수 있으며, 이 속성은 native <label> 요소를 활용하여 의미상 정확하고 액세스 가능한 레이블을 제공합니다.
접근성 권장사항을 지원하기 위해 구성요소는 관련 ARIA 속성도 적용합니다.
aria-invalid- 입력이 잘못된 상태인 경우 "true"로 설정합니다.
aria-describedby- 도우미 텍스트 요소가 있는 경우 자동으로 연결되어 보조 기술이 추가 정보를 알릴 수 있습니다.
Styling
이 컴포넌트는 스타일링에 사용할 수 있는 CSS 파트를 File Input 노출합니다. 다음 표에는 노출된 모든 CSS 부분이 나열되어 있습니다.
<!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