Skip to content

docs(actions): add note about enctype="multipart/form-data" for file … #11397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/content/docs/en/guides/actions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ Calling [Astro.getActionResult()](/en/reference/api-reference/#getactionresult)

To call an action from an HTML form, add `method="POST"` to your `<form>`, then set the form's `action` attribute using your action, for example `action={actions.logout}`. This will set the `action` attribute to use a query string that is handled by the server automatically.

Note: If your form includes file uploads, you must also add `enctype="multipart/form-data"` to the `<form>` element. This ensures that files are sent in a format that allows Astro's schema validation library to correctly recognize `z.instanceof(File)` inputs.

For example, this Astro component calls the `logout` action when the button is clicked and reloads the current page:

```astro title="src/components/LogoutButton.astro"
Expand Down