{"record":{"id":"7227ae807ae39c60","repo":"vercel/next.js","slug":"form-only-supports-file-inputs-if-action-is-a","errorCode":null,"errorMessage":"<Form> only supports file inputs if `action` is a function. File inputs cannot be used if `action` is a string, because files cannot be encoded as search params.","messagePattern":"<Form> only supports file inputs if `action` is a function\\. File inputs cannot be used if `action` is a string, because files cannot be encoded as search params\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/client/form-shared.tsx","lineNumber":90,"sourceCode":"    //  \"Set parsed action's query component to `query`.\"\n    //   https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#submit-mutate-action\n    //\n    // We need to match that.\n    // (note that all other parts of the URL, like `hash`, are preserved)\n    targetUrl.search = ''\n  }\n\n  const formData = new FormData(formElement)\n\n  for (let [name, value] of formData) {\n    if (typeof value !== 'string') {\n      // For file inputs, the native browser behavior is to use the filename as the value instead:\n      //\n      //   \"If entry's value is a File object, then let value be entry's value's name. Otherwise, let value be entry's value.\"\n      //   https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#converting-an-entry-list-to-a-list-of-name-value-pairs\n      //\n      if (process.env.NODE_ENV === 'development') {\n        console.warn(\n          `<Form> only supports file inputs if \\`action\\` is a function. File inputs cannot be used if \\`action\\` is a string, ` +\n            `because files cannot be encoded as search params.`\n        )\n      }\n      value = value.name\n    }\n\n    targetUrl.searchParams.append(name, value)\n  }\n  return targetUrl\n}\n\nexport function checkFormActionUrl(\n  action: string,\n  source: 'action' | 'formAction'\n) {\n  const aPropName = source === 'action' ? `an \\`action\\`` : `a \\`formAction\\``\n","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/client/form-shared.tsx#L72-L108","documentation":"createFormSubmitDestinationUrl serializes FormData for the submit target; when an entry's value is a File (from a file input) and the Form's action is a string (GET navigation), files cannot be encoded into search params, so this error is thrown to stop the submit.","triggerScenarios":"Thrown at packages/next/src/client/form-shared.tsx:90 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a function (Server Action) for `action` when the form contains file inputs, or remove the file input."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0eb377541648e63402a47b38fee00a8d0ce8f8f1","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}