Search This Blog

Friday, November 13, 2020

SPFx File upload control OnChange Event

 <div class="col-md-4 pt-3  text-right">
      <span class="uploadlink2 mouse_hover">                                                                            
         <label for="apfsFile" class="custom-file-upload">Upload File</label>
             <input style="display:none" type="file" id="FileInputId"  />
          </span>
 </div>


 var input = document.getElementById('FileInputId');
// This is only called when the input value
// is changed via the DOM, not when its changed
// programmatically using input.value
input.onchange = (e=> {  this.UploadFile(e);}

  public UploadFile(eventEvent): void {
    if ((event.target as HTMLInputElement).files && (event.target as HTMLInputElement).files.length) {
      //dosomething
    }
  }

No comments:

Post a Comment