You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is WIP for my use case that you can take a look at and see if it helps yours @sadeghhp.
exportclassFileUploadComponentimplementsControlValueAccessor{files: File[];onChange: (_)=>void;
@HostListener('change',['$event.target.files'])emitFiles(fileList: FileList){this.files=Array.from(fileList);this.onChange(this.files);}constructor(privatehost: ElementRef<HTMLInputElement>){}writeValue(value: null){// clear file inputthis.host.nativeElement.value='';this.files=[];}registerOnChange(cb){this.onChange=cb;}registerOnTouched(cb){}}exportfunctionrequiredFileTypes(allowedTypes: string[]){return(control: FormControl)=>{constfiles: File[]=control.value;if(files){// Is it enough to check the mime type string?constdoAllFileTypesRefenceAnAllowedType=files.every(file=>allowedTypes.some(allowedType=>file.type.includes(allowedType)));if(!doAllFileTypesRefenceAnAllowedType){return{requiredFileType: true};}returnnull;}returnnull;};}
<spanclass="fake-btn">Choose files</span><spanclass="file-msg">{{ files.length ? 'File(s) selected' : 'or drag and drop file here' }}</span><inputclass="file-input" type="file" multiple>
Hi,
What about multiple file upload?
The text was updated successfully, but these errors were encountered: