{"record":{"id":"302224aec021f9bd","repo":"sveltejs/kit","slug":"can-only-use-the-multiple-attribute-when-name","errorCode":null,"errorMessage":"Can only use the `multiple` attribute when `name` includes a `[]` suffix — consider changing \"${name}\" to \"${name}[]\"","messagePattern":"Can only use the `multiple` attribute when `name` includes a `\\[\\]` suffix — consider changing \"(.+?)\" to \"(.+?)\\[\\]\"","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/kit/src/runtime/client/remote-functions/form.svelte.js","lineNumber":543,"sourceCode":"\t\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t\t`Cannot mix and match file and non-file inputs under the same name (\"${element.name}\")`\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tvalue = is_file\n\t\t\t\t\t\t\t? elements.map((input) => Array.from(input.files ?? [])).flat()\n\t\t\t\t\t\t\t: elements.map((element) => element.value);\n\t\t\t\t\t\tif (element.type === 'checkbox') {\n\t\t\t\t\t\t\tvalue = /** @type {string[]} */ (value.filter((_, i) => elements[i].checked));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tset_nested_value(input, field, is_file ? value : coerce_form_value(field.type, value));\n\t\t\t\t} else if (is_file) {\n\t\t\t\t\tif (DEV && element.multiple) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Can only use the \\`multiple\\` attribute when \\`name\\` includes a \\`[]\\` suffix — consider changing \"${name}\" to \"${name}[]\"`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst file = /** @type {HTMLInputElement & { files: FileList }} */ (element).files[0];\n\n\t\t\t\t\tif (file) {\n\t\t\t\t\t\tset_nested_value(input, field, file);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tset_nested_value(input, field, DELETE_KEY);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tset_nested_value(\n\t\t\t\t\t\tinput,\n\t\t\t\t\t\tfield,\n\t\t\t\t\t\tcoerce_form_value(\n\t\t\t\t\t\t\tfield.type,\n\t\t\t\t\t\t\telement.type === 'checkbox' && !element.checked ? null : element.value","sourceCodeStart":525,"sourceCodeEnd":561,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/client/remote-functions/form.svelte.js#L525-L561","documentation":"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.","triggerScenarios":"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.","commonSituations":"Adding the multiple attribute to an existing single-file input without updating the name; following older multipart form examples that don't use [] naming.","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"],"exampleFix":"// before\n<input type=\"file\" name=\"uploads\" multiple />\n// after\n<input type=\"file\" name=\"uploads[]\" multiple />","handlingStrategy":"validation","validationCode":"function assertMultipleNaming(form) {\n  for (const el of form.querySelectorAll('input[type=\"file\"][multiple]')) {\n    if (!el.name.endsWith('[]')) throw new Error(`rename ${el.name} to ${el.name}[]`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always suffix multi-value inputs with []","Review forms after adding the multiple attribute","Run dev-mode smoke tests on forms with file uploads"],"tags":["dev-mode","formdata","remote-forms","file-upload"],"backgroundTag":"multiple-attribute-requires-bracket-suffix","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}