title: Programmatically upload file on Sharepoint using ReactJs
body: <p>I am new to use ReactJS, I need community help to solve my problem statement.</p>
  <p>Problem statement :- I want to upload image file in Sharepoint using ReactJS and as response I want back image's Sharepoint URL, so that I can save in data base to display those images in my application pages.
  I am developing a web app and this app is running under teams as tab.</p>
  <p>Here is one reference link I have tried but I am unable implement successfully.</p>
  <p><a href="http://siddharthvaghasia.com/2019/10/16/upload-file-to-sharepoint-library-using-file-control-and-pnp-js-in-spfx-webpart/" rel="nofollow noreferrer">http://siddharthvaghasia.com/2019/10/16/upload-file-to-sharepoint-library-using-file-control-and-pnp-js-in-spfx-webpart/</a></p>
  <p>After implementing this I am getting following error:-</p>
  <p>TypeError: Cannot read property 'getFolderByServerRelativeUrl' of undefined
  Settings.uploadFileFromControl
  src/components/Settings.jsx:656</p>
  <pre><code>  653 | //var files = this._input.files;
    654 | //var file = files[0];
    655 | //Upload a file to the SharePoint Library`enter code here`
  &gt; 656 | sp.web.getFolderByServerRelativeUrl(this.props.context.pageContext.web.serverRelativeUrl)
        | ^  657 | //sp.web.getFolderByServerRelativeUrl(this.props.context.pageContext.web.serverRelativeUrl + &quot;/MyDocs&quot;)
    658 | .files.add(file.name, file, true)
    659 | .then((data) =&gt;{
  </code></pre>
  <p>View compiled
  FileReader.reader.onloadend
  src/components/Settings.jsx:603</p>
  <pre><code>  600 | 
    601 | //console.log('fileVar[i].name ' + reader.fileName);
    602 | 
  &gt; 603 | this.uploadFileFromControl(fileVar[i]);
        | ^  604 | 
    605 | logoImages.push({image: reader.result, name: reader.fileName});
    606 | this.setState({eventLogoImageUrl: JSON.stringify(logoImages)});
  </code></pre>
  <p>I am not getting this weather this sp.web will work under teams app or not?</p>
  <p>Please help
  Thanks in advance.</p>