Skip to the content

File dropzone

A file field written as plain markup: a zone, a real file input inside it, a line of help.

Become a member to unlock the full effect today.

Join now

Already a member? Sign in

Documentation

  1. Copy to Webflow

    Add Geist and Geist Mono to your site's fonts (Site settings, Fonts, Google Fonts) before pasting: Webflow removes any font your site has not installed.

  2. Add custom CSS

    The look of the preview is the file-dropzone-* classes of the paste: the zone at rest, its sentence, the label and the hint. The Embed holds what moves, the sheet and the lines of the list, and reads four variables, --file-dropzone-ink, --file-dropzone-ground, --file-dropzone-accent and --file-dropzone-error: set them on the field, or on anything above it, in a rule of your own. The words on the sheet take the type of the zone, and its top and bottom padding.
  3. Add custom JS

  4. Use it on your own elements

    Custom attributes
    Select the element on the canvas and open the Settings panel. Under Custom attributes, add a pair: the name on the left, the value on the right.
    Custom attributeWhat it does
    data-file-dropzone Marks the field: the block that holds the zone, the list of files and the hint. It takes no value: leave the value field empty. The settings below go on the same element.
    data-file-dropzone-zone On the box a file is dropped on, which holds the file input. It takes no value. The engine lays the input over it, so a click anywhere opens the picker, and draws the sheet that rises in it. Its top and bottom padding are the sheet's. Without it the parent of the input is taken. [ Required ]
    data-file-dropzone-label On the words that name the field, when they are not a label element, which Webflow only has inside a form. It takes no value. The engine names the input by them for a screen reader. [ Optional ]
    data-file-dropzone-hint On the line of help. It takes no value. The reason takes its place when a file is refused, then the hint comes back. A field without one gets a line from the engine. [ Optional ]
    data-file-dropzone-pointer On words that only make sense with a mouse, "or drop them here". It takes no value. They are left out on a touch screen. [ Optional ]
    data-file-dropzone-list Optional, on a list of your own where the lines of the files go. It takes no value. Without it the engine adds the list under the zone. [ Optional ]
    data-file-dropzone-state Written by the engine on the field: focus, filled, busy, error, disabled, and during a drag armed, then over or refuse, several at once. Each line of the list carries data-file-dropzone-row: loading, done, failed or out. Never written by hand; the stylesheet reads them, and so can a rule of yours. [ Optional ]
    Settings
    Every setting is a custom attribute too, added the same way and on the same element. An attribute always wins over the defaults written in the code.
    AttributeDefaultWhat it is
    data-file-dropzone-max-size 0 The largest file the field takes, in megabytes (1 MB is 1 000 000 bytes). A heavier file is refused with the words of size.
    data-file-dropzone-max-files 0 The most files the field holds at once, when its input carries multiple. The files beyond it are refused with the words of count.
    data-file-dropzone-upload empty The address each file is posted to as soon as it is added, alone, as multipart/form-data under the name of the input. Empty, the default: nothing is posted, the files stay in the input and leave with the form. Options: empty; or an address, https://example.com/upload, which must answer in the 200s and allow the page's origin.
    data-file-dropzone-paste field Where a file pasted from the clipboard, a screenshot for one, is heard. Options: field, the default, when the focus is in the field; page, anywhere on the page, the file going to the field that has the focus or to the first field set to page; off, never.
    data-file-dropzone-drop Release to add The words in the open slot, while a file is held over the zone. Options: any text, in the language of the page.
    data-file-dropzone-type {name} is not an accepted type. The reason under the field when a file is not of an accepted type. {name} is the name of the file. Options: any text, in the language of the page.
    data-file-dropzone-size {name} is over {max}. The reason under the field when a file is over maxSize. {name} is the name of the file, {max} the limit as it is read, 10 MB. Options: any text, in the language of the page.
    data-file-dropzone-count {max} files at most. The reason under the field when more files are offered than maxFiles. {max} is the limit. Options: any text, in the language of the page.
    data-file-dropzone-required Add a file. The reason under a field whose input carries required, when its form is sent with no file. Options: any text, in the language of the page.
    data-file-dropzone-busy Wait for the files to finish. The reason under the field when its form is sent while a file is still uploading. Options: any text, in the language of the page.
    data-file-dropzone-failed Failed The word on the line of a file whose upload failed, when no reason was given. Options: any text, in the language of the page.
    data-file-dropzone-retry Retry The word of the button that sends such a file again. Options: any text, in the language of the page.
    data-file-dropzone-remove Remove The name of the cross that removes a file, read aloud by a screen reader before the name of the file. Options: any text, in the language of the page.
    The way the files are sent
    This field is not Webflow's own File upload button. That button, Webflow's help says, exists on the Premium (legacy Business), Ecommerce Plus and Ecommerce Advanced site plans and "accepts a single file of up to 10MB"; this field is one input that holds several files. The paste is plain blocks, with the file input in a small Embed inside the zone: open that Embed to change its name, accept, multiple or required. Drag the field into a Form block of your own, then choose how the files leave. In the form's settings, under Send to, a Custom action with the method POST hands the form to the address you give, a form service or an endpoint of your own that accepts files, and bypasses Webflow's own handling. Or add data-file-dropzone-upload on the field with the address that receives each file as it is added. Neither depends on the site plan. Do not count on a form that Webflow collects itself to carry the files: Webflow documents only its own button for that, and this was not tried on a live site. The preview sends nothing.
    Custom attributeWhat it does
    data-file-dropzone-upload="https://..." On the field: posts each file to that address as soon as it is added, alone, as multipart/form-data under the name of the input, with the header Accept: application/json. An answer in the 200s shows the file as taken and puts the url or the id of a JSON answer, or the answer as text, in a hidden field of the same name; anything else shows Failed and a Retry. The address must allow the page's origin.
    data-file-dropzone-max-size="10" On the field: the largest file taken, in megabytes. HTML has no attribute for it.
    data-file-dropzone-max-files="5" On the field: the most files held, for an input that carries multiple. HTML has no attribute for it.
    accept, multiple, required, name On the input itself, as on any file input: the types taken, several files or one, a field that cannot be left empty, and the name the files are sent under. In Webflow the input is in the small Embed inside the zone.

What it does

File dropzone is an animated form for Webflow and vanilla JavaScript, with no library. Also called drag and drop file upload, multiple file upload or custom file upload field.

A file field written as plain markup: a zone, a real file input inside it, a line of help. At rest it is one sentence on a rule, in the register of the Form set. A file dragged over the page makes a sheet of ink show its edge under the rule; over the zone the sheet rises to the top with the words of the drop and the number of files in the hand; on release it falls back and each file comes out from under the rule as a line of the list. There is no progress bar: the name of the file is grey and is inked from the left as far as the upload has gone, while a small count runs beside it and becomes the size and a drawn tick. A file is removed by a cross, its name struck through before the row closes. Types and number come from the input's own accept and multiple, weight and count from two attributes; a refused file never enters the list, and the reason is written under the field. The input is the browser's own, so the keyboard, a screen reader, a form and a page without JavaScript all use it as any file field; the files dropped or pasted are written into it, so a form sends exactly what the list shows. Each file can also be posted to an address as it is added. Reduced motion respected. No library. Pattern type file upload, dropzone, attachment field.

Updated

Questions

Webflow's own File upload button takes one file each. This field is a single <input type="file" multiple>, placed in a small Embed inside a block marked data-file-dropzone-zone: it holds as many files as data-file-dropzone-max-files allows, and lists them under the zone. Send the form to a Custom action that accepts files, or post each file to an address with data-file-dropzone-upload.

Webflow's File upload button belongs to the Premium, Ecommerce Plus and Ecommerce Advanced site plans. This field does not use it, so it does not depend on the plan, but Webflow then does not store the files: they go to the address of a Custom action, or to the one named in data-file-dropzone-upload.

The types are the input's own accept attribute, accept="application/pdf,image/*", checked again on a drop and on a paste. The weight is data-file-dropzone-max-size, in megabytes, and the number of files data-file-dropzone-max-files, both on the field. A refused file never enters the list, and the reason is written under the field. The receiving end must check too.

Here the name of each file is the progress: it is grey when the file is added and is inked from the left as far as the upload has gone, beside a small count that becomes the size and a tick. With data-file-dropzone-upload the engine follows the real request; a page that sends the file itself reports with detail.progress() from the event filedropzone:upload.

The zone is a real file input laid over it, not a div with a click handler: Tab reaches it, Space or Enter opens the browser's picker, and a screen reader announces a file field with its label and its hint. Each file has a remove button named after it, refusals are announced, and without JavaScript the browser's own control shows.

Yes. With the focus in the field, a file pasted from the clipboard is added like a dropped one and goes through the same checks. data-file-dropzone-paste="page" takes a paste made anywhere on the page, and off turns it off. Pasted text is never touched.