Below is the Typescript code for uploading a Zip file:
fileUploader(event:Event):void{
const target = event.target as HTMLTextAreaElement;
this.fileInfo= target.files[0];
}
onNoClick(): void {
this.dialogRef.close({location: this.lastNode, cancel: true});
}
closeDialog(): void {
console.log(this.versionNote);
let data={'file':this.fileInfo,'versionNote':this.versionNote};
this.dialogRef.close(data);
}
HTML code for the upload functionality:
<h1 mat-dialog-title>{{'DOCUMENT_LIST.CONTENT.UPLOAD_ZIP' | translate}}</h1>
<div><span class="ng-star-inserted"><h3><b>Folder Name: {{folderName}}</b></h3></span></div>
<input type="file" id="file" [(ngModel)]="playerName" (change)="fileUploader($event)">
<p>
<mat-form-field class="example-full-width">
<textarea matInput placeholder="Notes" [(ngModel)]="versionNote"></textarea>
</mat-form-field>
</p>
<div mat-dialog-actions>
<button mat-button (click)="onNoClick()">{{'OPTIONS.CANCEL' | translate}}</button>
<button mat-button cdkFocusInitial (click)="closeDialog()">{{'OPTIONS.UPLOAD' | translate}}</button>
</div>
An error occurs during runtime with the following message:
Property 'files' does not exist on type 'HTMLTextAreaElement'.