Marcin Paukštelo
Marcin Paukštelo

Reputation: 11

How to pass array of Files to Server Action?

NEXTJS

I am trying to to submit a form to server action with array of Files.

const onSubmit = async (data: PostData) => {
    const result = await createPostAction(data);

When I try to submit I am getting an error:

Error: Only plain objects, and a few built-ins, can be passed to Server Actions. Classes or null prototypes are not supported.

This error disappears if do not include an array of Files (images) in my form:

enter image description here

Is there any way to bypass this or submit files to server actions in other way?

Upvotes: 0

Views: 351

Answers (0)

Related Questions