#useFetcher() with files

1 messages · Page 1 of 1 (latest)

main parcel
#

Hey everyone,
Did anyone use useFetcher() before to upload files?

fetcher.submit(
 {
  img: files[0]
 },
 { 
  encType: "multipart/form-data", 
  method: "post", 
  action: "/route" 
 }
)
karmic wind
floral idol
#

Have you tried creating a FormData and appending the files to the FormData and send that ?

karmic wind
#

but never files so far

floral idol
#
const formData = new FormData();
formData.append("img", files[0]);
fetcher.submit(formData, {
  encType: "multipart/form-data", 
  method: "post", 
  action: "/route" 
})

something like that ... Where do you get the files from ?

main parcel
#

😁 I forget all about formData on the client

#

It worked