How do i find my uploaded files in html?

File upload is a common functionality many web applications provide to users. With file upload functionality, you may want to provide the users with the ability to view it on your web page. But the question remains: 

How to display uploaded files in HTML using JavaScript? Also, how you can conveniently and efficiently achieve that.

This article describes how you can use a JavaScript file uploader and how Filestack can help you display the uploaded files easily with their components and API. 

  • How to Upload Files in JavaScript?
  • Can You Use Filestack to Integrate a File Uploader?
  • How Do I Display Uploaded Files in HTML Using JavaScript?
  • Using Filestack
  • How can Filestack help you?

How to Upload Files in JavaScript?

Let’s first see how you can upload files in JavaScript. The most common file types users need to upload are images and PDF documents. 

First, you must add functionality to select the files from your desired location. 

There are a few ways you can upload a file in JavaScript. If you use pure JavaScript, you can add the following HTML5 file selector and an upload button on your web page:

“upload” type=“file” name=“upload” />
<button id=“btnUpload” onclick=“fileUpload()”> Upload Filebutton>
Then you need to write the JavaScript function that triggers the file upload.
<script>
async function fileUpload() {
    let data= new FormData();          
    data.append(“file”, upload.files[0]);
    await fetch(‘/upload.php, {
      method: “POST”,
      body: data
    });   
}

Finally, you must write the server-side code to handle the file upload. If you want to learn how to upload a CSV file in React JS, read this article

Can You Use Filestack to Integrate a File Uploader?

However, writing file upload functionality from scratch can take time, especially if you want to achieve a sleek design for your uploader. 

The easiest way to add file upload functionality for your UI is by using a third-party file upload library. 

For example, you can use the Filestack File picker and its File API to get files selected, uploaded, and ready for delivery. 

You just have to include our JavaScript SDK UMD module of Filestack API in your application code to start using the Filestack File Picker. For example:

Some websites may click on the uploaded document and let users preview the uploaded file in a separate window. 

Whatever way you want to display the file, you want to achieve that with less coding. Let’s see how to display an image in pure JavaScript.

First, create the place where you want to display the uploaded file:

‘display_file’ > <div>
const file = document.querySelector(‘#upload’);
Var uploadedFile = “”;
file.addEventListener(‘change’ , function () {
    const reader = new FileReader();
    reader.addEventeListener (‘load’, function () {
        uploadedFile = reader.result;
  document.querySelector(‘#display_file’).style.backgroundImage = url  ({uploadedFile});
        reader.readDataURL(this.files[0]);
  })

})

Read this article to learn how to read uploaded file content in JavaScript.

Using Filestack

The above code will display the uploaded image file within the webpage. However, there are many easy ways you can do that using a third-party JavaScript library in many easy ways. 

For example, Filestack offers a document viewer from which you can display the uploaded file to the user in the browser. 

It combines its processing engine with a custom solution built on Mozilla’s PDF.js and supports many file types, including PDF files (PDF), PowerPoint files (PPT, PPTX), Excel files (XLS, XLSX), Word files (DOC, DOCX, Image files (gif, tiff, jpg, jpeg, png), and more.

To view the files in HTML, you need to include the following file in your HTML code as an iframe element. For example: