FilePond Image Upload with Reorder — Free JS Snippet

FilePond Image Upload with Preview and Reorder · Forms · Plain HTML, CSS & JS · Live preview

CategoryForms

What's included

Features

Drag-and-drop and click-to-browse with animated thumbnail previews
Drag-to-reorder using allowReorder and the reorderfiles event
Numbered upload-order strip that marks the first file as the cover
Image-only validation with a friendly rejection message
Maximum file count with a live counter
instantUpload: false keeps files local until the form is submitted
storeAsFile: true, so a normal multipart form post includes the files
Plug-ins registered up front: image preview and file-type validation

About this UI Snippet

FilePond Image Upload with Preview and Reorder — HTML, CSS & JavaScript

Screenshot of the FilePond Image Upload with Preview and Reorder snippet rendered live

A plain file input is functional and unfriendly: no preview, no progress, no way to tell whether the file you picked is the one you meant, and nothing to help you change your mind. FilePond replaces it with a proper upload component — drag-and-drop, thumbnails, remove buttons, animations — while remaining a genuine form field underneath. This snippet uses it for a common real-world job, a listing-photo uploader where the order matters because the first image becomes the cover.

FilePond's power comes from its plug-in model. The core library handles files, states and the UI shell; image previews and type validation are separate plug-ins that must be registered before an instance is created — FilePond.registerPlugin(FilePondPluginImagePreview, FilePondPluginFileValidateType). Skipping this step is the most common mistake: options such as imagePreviewHeight and acceptedFileTypes are silently ignored without the plug-ins that read them. The demo loads each plug-in's script, plus the CSS for the core and the preview plug-in, from a CDN.

Reordering is a single option: allowReorder: true lets users drag items up and down, and the reorderfiles event fires when they do. The snippet listens to that event along with addfile, removefile and updatefiles to redraw a numbered "upload order" strip beneath the field, marking position one as the cover. That order is also the order in which the files will be submitted, which is the whole point of letting people arrange them.

Two options define how the upload works with forms. instantUpload: false keeps files on the client until the surrounding form is submitted, rather than firing a request per file the moment it is added. storeAsFile: true writes the selected files back into a real file input so a normal multipart form post includes them, with no server endpoint or custom upload code required for the simplest case; for API-style uploads you would configure server processing instead. maxFiles enforces the cap of six, acceptedFileTypes restricts to images, and labelFileTypeNotAllowed gives a clear rejection message. Three generated sample photos are added at startup so the drag handles are visible straight away.

Build with AI

Build, Understand, Optimize, and Extend It With AI

Ask an AI assistant like Claude to add image resizing and cropping with the image-transform plug-in, wire the field to a real upload endpoint with progress bars, or add EXIF orientation correction.

Prompt to recreate it

Copy this into your AI assistant of choice to build the effect from scratch, or as a jumping-off point for your own variant:

text
Build a multi-image upload field with FilePond 4 loaded from a CDN (core script and CSS, image preview plug-in script and CSS, file-validate-type plug-in).

Requirements:
- Register FilePondPluginImagePreview and FilePondPluginFileValidateType before calling FilePond.create on a file input.
- Set allowMultiple, allowReorder, maxFiles: 6, acceptedFileTypes for PNG/JPEG/WebP/GIF, instantUpload: false and storeAsFile: true, with a custom label and file-type-rejected message.
- Show a live "n / 6" counter and a numbered upload-order strip that marks the first file as the cover, updated on addfile, removefile and reorderfiles events.
- Pre-load three generated sample images with pond.addFiles so reordering can be seen straight away.

Want to tighten it up first? Run this prompt through the AI Prompt Studio to score it across 8 quality dimensions, catch anti-patterns, and tune the wording for Claude, ChatGPT, or Gemini before you paste it in.

Source Code

<div class="fu-card">
  <div class="fu-head">
    <h3>Listing photos</h3>
    <span class="fu-count" id="fuCount">0 / 6</span>
  </div>
  <p class="fu-sub">Drop images, or browse. Drag thumbnails to reorder &mdash; the first photo becomes the cover.</p>
  <input type="file" id="fuInput" class="filepond" name="photos" multiple accept="image/*">
  <div class="fu-order" id="fuOrder" aria-live="polite"></div>
</div>

Step by step

How to Use

  1. 1
    See the pre-loaded photosThree sample images appear as thumbnails, numbered in the order strip below with the first marked as the cover.
  2. 2
    Reorder themDrag a thumbnail up or down. The numbered strip updates to show the new upload order and cover.
  3. 3
    Add your ownDrop image files onto the field, or click Browse. Non-image files are rejected with a clear message.
  4. 4
    Hit the limitAdd up to six photos. The counter shows the total and further files are refused.
  5. 5
    Remove oneUse the remove button on a thumbnail; the strip and counter update immediately.

Real-world uses

Common Use Cases

SHOP
Marketplace and listing photos
Let sellers arrange product images with a cover. Combine with the Cropper.js presets to frame each photo first.
Profile and portfolio galleries
Collect a set of images where display order matters.
ADMIN
CMS media uploads
Give editors previews and validation before anything is sent to the server.
Learning plug-in architectures
Shows why a library's options depend on registering its plug-ins first.

Got questions?

Frequently Asked Questions

Options like imagePreviewHeight and acceptedFileTypes belong to plug-ins. Call FilePond.registerPlugin with those plug-ins before FilePond.create.

Set allowReorder: true and listen for the reorderfiles event, then read the new order with pond.getFiles().

It places the selected files back into a real file input, so a standard form submission includes them without a custom upload server.

Leave instantUpload on and configure the server option with process and revert endpoints or functions.

Register FilePondPluginFileValidateType and set acceptedFileTypes, e.g. ["image/png", "image/jpeg"], plus a custom label.

Set maxFiles. FilePond refuses additional files once the limit is reached.

Yes. Use the JSX, Vue, Angular or Tailwind export buttons on this page to convert the markup and styles. The behaviour comes from FilePond, so in a framework project install it with npm install filepond filepond-plugin-image-preview filepond-plugin-file-validate-type (or react-filepond / vue-filepond / ngx-filepond) instead of the CDN tag, register the plug-ins once, then create the pond in an effect, and release it with destroy() when the component unmounts.