How to browse uploaded files in the widget

Often you may want to allow a user to choose previously uploaded files again. Uploadcare doesn’t store relations between users and files and also doesn’t allow the widget to list all files in the project for security reasons.

There are two ways to handle files-to-user relations:

  1. You can store this information on your side and load list of user’s files using AJAX requests to your server. This is a relatively complex way because you’ll need to implement some storage and endpoint which will return a file list from this storage.

  2. List of previously uploaded files can be stored locally on the user’s computer in browser’s local storage. This way user will not be able to choose files uploaded from other devices, but this doesn’t require any support on the server side.

Following example shows how to add local storage history tab with the following features:

  • Lists are separated by a public key. If you are using widgets with two or more public keys, only files from the current project will be shown.
  • List of last 50 files is shown.
  • If the widget has the images-only flag, only image files will be shown.
  • User can remove files from history.

See how to implement this.