Skip to content

App Router: File Upload File objects are not supported #50358

Answered by icyJoseph
Rykuno asked this question in App Router
Discussion options

You must be logged in to vote

What I tried first

With this use client page component:

"use client";
import { uploadFile } from "./actions";

export default function Home() {
  return (
    <form className="flex flex-col items-end">
      <input name="fileUpload" type="file" />
      <button
        className="text-white bg-blue-700 p-2 rounded"
        formAction={uploadFile}
      >
        Upload!
      </button>
    </form>
  );
}

And this action:

"use server";

export async function uploadFile(data: FormData) {
  const file = data.get("fileUpload");
  console.log(file);
}

I get this:

Screen.Recording.2023-05-26.at.07.36.55.mov

A fix for your situation

So that means that in your case the problem is that yo…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@Rykuno
Comment options

@elbracht
Comment options

@masadamsahid
Comment options

Answer selected by Rykuno
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants