0

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

<input type="file" name="file" id="file">
<ion-button  onclick="uploadPDF()" name="submit">
  Upload File
</ion-button>


<script>
  function uploadPDF() {
  let data = document.getElementById("file").files[0];
  let entry = document.getElementById("file").files[0];
  console.log('uploadPDF',entry,data)
  fetch('uploads/' + encodeURIComponent(entry.name), {method:'PUT',body:data});
  alert('your file has been uploaded');
  location.reload();
};
</script>

When the upload file button is clicked a prompt should appear that says 'your file has been uploaded' however this does not occur

1 Answer 1

1

You have to use these two plugins:

You can upload the file to your server and then get the URL to view it in the app.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.