Filepicker.js Client Library

2.4.18 · deprecated · verified Sun Apr 19

The `filepicker-js` package is the JavaScript client library for the original Filepicker.io service, which was acquired and rebranded as Filestack in 2015. The library's latest version, 2.4.18, was published over 10 years ago, indicating it is no longer actively maintained under this name. Modern development and new features are now exclusively available through the `filestack-js` SDK. This library primarily provides methods for file picking, storing, reading, writing, and basic image transformations, facilitating direct integration of file upload capabilities from various sources into web applications. It supports traditional browser script tag inclusion, exposing `window.filepicker`, and CommonJS `require()` for compatibility with older bundlers like Browserify. Its primary differentiator was simplifying file ingestion from diverse sources into web applications.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to integrate `filepicker-js` into an HTML page, set the API key, and initiate a file selection and upload process using the `pick` method, displaying the uploaded file's URL.

<html>
<head>
  <title>Filepicker.js Quickstart</title>
</head>
<body>
  <h1>Upload a File with Filepicker.js</h1>
  <button id="upload-button">Pick File</button>

  <script type="text/javascript" src="//api.filepicker.io/v2/filepicker.js"></script>
  <script type="text/javascript">
    // Replace with your actual API key from Filepicker.io (or Filestack)
    const API_KEY = process.env.FILEPICKER_API_KEY ?? 'YOUR_FILEPICKER_API_KEY';

    (function(){
      if(!window.filepicker) {
        console.error('Filepicker.js failed to load.');
        return;
      }

      filepicker.setKey(API_KEY);

      document.getElementById('upload-button').addEventListener('click', function() {
        filepicker.pick({
          mimetype: 'image/*',
          container: 'window',
          services: ['COMPUTER', 'DROPBOX', 'GOOGLE_DRIVE', 'FACEBOOK']
        }, function(Blob){
          console.log('Upload successful! File details:', JSON.stringify(Blob));
          alert('File uploaded: ' + Blob.url);
        }, function(FPError){
          console.error('Upload failed:', FPError.toString());
          alert('File upload failed: ' + FPError.toString());
        });
      });

      console.log('Filepicker.js initialized. Click the button to pick a file.');
    })();
  </script>
</body>
</html>

view raw JSON →