Skip to content
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

why am i getting this isses, please someone help. FormData { file name → {} } #13107

Open
olamide-thinker opened this issue Apr 23, 2024 · 2 comments
Labels
needs-reproduction We can't reproduce so it's blocked

Comments

@olamide-thinker
Copy link

i have tried all i can looked everywhere i can and this just persist for no reason i can fathom. please can any one help me.

i want to upload a profile picture to an end point but this just seem to be an obstacle i cant find a get around for

const handleImageChange = (event: React.ChangeEvent) => {
const file = event.target.files?.[0];
console.log("Pics", file);

if (file) {
  let formData = new FormData();
  formData.append("file", file);
  console.log("form content", formData);
}

setOpen(false);

};

@denihs
Copy link
Contributor

denihs commented Apr 23, 2024

It's difficult to understand what's happening from just this snippet of code. Can you provide a reproduction of this problem?

I've been doing some things recently with files and didn't have problems like this.

If you provide a reproduction, it'll be easier to help.

@StorytellerCZ StorytellerCZ added the needs-reproduction We can't reproduce so it's blocked label Apr 24, 2024
@olamide-thinker
Copy link
Author

okay, thank you @StorytellerCZ

first or all, i am using the following dependencies for my ui:

  • shadcn
  • next
  • nextui

i am trying to upload a file to the server and soon as i noticed its now working i decided to console.log what i am getting from the formData and found this :

if (file) {
let formData = new FormData();
formData.append("profile_pic", file , file.name); // Append the file with its name
console.log("Form content:", formData);
}

console log result: FormData { profile_pic → {} }

if (file) {
let formData = new FormData();
formData.append("profile_pic", file.name); // Append the file with its name
console.log("Form content:", formData);
}

console log result: FormData { profile_pic → "profileImage.webp" }

its not uploading the image file. returned {}

so i started trouble shooting and still that issue persist. i don't know what to do. does this mean i can upload life or images for some reasons i can fathom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-reproduction We can't reproduce so it's blocked
Projects
None yet
Development

No branches or pull requests

3 participants