Next.js Discord

Discord Forum

Passing file from client to server action

Unanswered
Polar bear posted this in #help-forum
Open in Discord
Polar bearOP
I want to pass a file from an input from the client to a server action to upload it. In the end I want to upload the Uint8Array of the file. I can't pass the File directly, so can I pass it any other way?

3 Replies

Polar bearOP
I'm not using a server action directly though, I first use onSubmit, and then I want to use a server action to upload the image, not submit the whole form. Sorry if I explained it vague, and sorry that my code's so weird :)
there are only a few valid types you can send and formdata is the best one for file i am pretty sure (you could base64 or send the array as list, but i think just making formdata and adding file is fine)