Skip to content

Cannot set form field and immediately submit #15009

@hyunbinseo

Description

@hyunbinseo

Describe the bug

Invalid type: Expected File but received undefined

[[1,2],{"file":-1},{}] # Request Payload
<script lang="ts">
  import { uploadBinary } from './upload.remote';

  let submit: HTMLButtonElement;
</script>

<form {...uploadBinary} enctype="multipart/form-data">
  <input {...uploadBinary.fields.file.as('file')} hidden />
  <button bind:this={submit} hidden>Submit</button>
</form>

<button
  type="button"
  onclick={() => {
  uploadBinary.fields.set({ file: new File([], 'file.txt') });
  submit.click();
  }}>Set Fields and Immediately Submit</button
>

<ul>
  {#each uploadBinary.fields.allIssues() as issue}
  <li>{issue.message}</li>
  {/each}
</ul>

Reproduction

https://github.com/hyunbinseo/svelte-kit-15009

System Info

System:
  OS: Windows 11 10.0.26200
  CPU: (8) x64 Intel(R) Core(TM) Ultra 7 258V
  Memory: 2.27 GB / 31.48 GB
Binaries:
  Node: 24.11.0 - C:\Users\hyunb\AppData\Local\fnm_multishells\14828_1764471146040\node.EXE
  Yarn: 1.22.22 - C:\Users\hyunb\AppData\Local\fnm_multishells\14828_1764471146040\yarn.CMD
  npm: 11.6.1 - C:\Users\hyunb\AppData\Local\fnm_multishells\14828_1764471146040\npm.CMD
  pnpm: 10.24.0 - C:\Users\hyunb\AppData\Local\fnm_multishells\14828_1764471146040\pnpm.CMD
  Deno: 2.4.0 - C:\Users\hyunb\.deno\bin\deno.EXE
Browsers:
  Chrome: 142.0.7444.176
  Edge: Chromium (140.0.3485.54)
  Firefox: 145.0.2 - C:\Program Files\Mozilla Firefox\firefox.exe
npmPackages:
  @sveltejs/adapter-auto: ^7.0.0 => 7.0.0
  @sveltejs/kit: ^2.48.5 => 2.49.0
  @sveltejs/vite-plugin-svelte: ^6.2.1 => 6.2.1
  svelte: ^5.43.8 => 5.45.2
  vite: ^7.2.2 => 7.2.4

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions