sveltejs/kit · error
Can only use the `multiple` attribute when `name` includes a
Error message
Can only use the `multiple` attribute when `name` includes a `[]` suffix — consider changing "${name}" to "${name}[]" What it means
A multi-file input (<input type="file" multiple>) inside a remote form must have a name ending in [] so SvelteKit serializes it as an array. Dev mode throws with a concrete rename suggestion when multiple is set without the suffix.
Source
Thrown at packages/kit/src/runtime/client/remote-functions/form.svelte.js:543
throw new Error(
`Cannot mix and match file and non-file inputs under the same name ("${element.name}")`
);
}
}
}
value = is_file
? elements.map((input) => Array.from(input.files ?? [])).flat()
: elements.map((element) => element.value);
if (element.type === 'checkbox') {
value = /** @type {string[]} */ (value.filter((_, i) => elements[i].checked));
}
}
set_nested_value(input, field, is_file ? value : coerce_form_value(field.type, value));
} else if (is_file) {
if (DEV && element.multiple) {
throw new Error(
`Can only use the \`multiple\` attribute when \`name\` includes a \`[]\` suffix — consider changing "${name}" to "${name}[]"`
);
}
const file = /** @type {HTMLInputElement & { files: FileList }} */ (element).files[0];
if (file) {
set_nested_value(input, field, file);
} else {
set_nested_value(input, field, DELETE_KEY);
}
} else {
set_nested_value(
input,
field,
coerce_form_value(
field.type,
element.type === 'checkbox' && !element.checked ? null : element.valueView on GitHub (pinned to 03f1687fe6)
Solutions
- Rename the input's name to include a [] suffix, e.g. name="files" becomes name="files[]"
- Remove the multiple attribute if only one file is expected
- Update the remote function's argument shape to expect an array for that field
Example fix
// before <input type="file" name="uploads" multiple /> // after <input type="file" name="uploads[]" multiple />
Defensive patterns
Strategy: validation
Validate before calling
function assertMultipleNaming(form) {
for (const el of form.querySelectorAll('input[type="file"][multiple]')) {
if (!el.name.endsWith('[]')) throw new Error(`rename ${el.name} to ${el.name}[]`);
}
} Prevention
- Always suffix multi-value inputs with []
- Review forms after adding the multiple attribute
- Run dev-mode smoke tests on forms with file uploads
When it happens
Trigger: Submitting an enhanced remote form containing <input type="file" multiple name="files"> where the name lacks the [] suffix, detected in handle_input when the first selected file is processed.
Common situations: Adding the multiple attribute to an existing single-file input without updating the name; following older multipart form examples that don't use [] naming.
Related errors
- Cannot mix and match file and non-file inputs under the same
- Your form contains <input type="file"> fields, but is missin
- `$` is used to collect all FormData validation issues and ca
- exports is not available in dev mode
- Your form contains <input type="file"> fields, but is missin
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/302224aec021f9bd.
Report an issue: GitHub.