Skip to main content

Posts

Showing posts from March, 2020

SPFx File Upload using Pnp

Today I came across a requirement to upload file to SharePoint Document library. This task was to be done using SPFx. Pnp helped me with this. Here is the code i used. Below is the code for uploading file and meta data. private   UploadFile ():  void  {          let   input  = < HTMLInputElement >  document . getElementById ( "fileUpload" );          let   files  =  input . files ;          for  ( let   index  =  0 ;  index  <  files . length ;  index ++) {              const   file  =  files [ index ];              if  ( file . size <=  10485760 )    {      //upload small file in document library           pnp . sp . web . getFolderByServerRelativeUrl ( "/sites/Dummy/ProcessDocuments/" ). files . add ( file . name ,  file ,  true ). then ( f =>  {                   f . file . getItem (). then ( item   =>  {                      item . update ({ ProcessInformationIDId:   itemID }). then ( f   =>  {