title: how to upload and view a PDF file in angular using Ionic?
body: <p>I'm working with angular and ionic at the moment and I need to be able to upload and view a PDF file. So far I can choose the pdf file, however I'm having issues with upload it. This is my code thus far</p>
  <pre><code>&lt;input type=&quot;file&quot; name=&quot;file&quot; id=&quot;file&quot;&gt;
  &lt;ion-button  onclick=&quot;uploadPDF()&quot; name=&quot;submit&quot;&gt;
    Upload File
  &lt;/ion-button&gt;
  
  
  &lt;script&gt;
    function uploadPDF() {
    let data = document.getElementById(&quot;file&quot;).files[0];
    let entry = document.getElementById(&quot;file&quot;).files[0];
    console.log('uploadPDF',entry,data)
    fetch('uploads/' + encodeURIComponent(entry.name), {method:'PUT',body:data});
    alert('your file has been uploaded');
    location.reload();
  };
  &lt;/script&gt;
  </code></pre>
  <p>When the <code>upload file</code> button is clicked a prompt should appear that says 'your file has been uploaded' however this does not occur</p>