Skip to content

JavaScript file upload #4901

Answered by ViniciusMarchi
stanmertens asked this question in Q&A
Discussion options

You must be logged in to vote

Hello, I think I can help you with that. First, let's explain some points. In the example repository that you share you are using fetch and FormData to make request to FlaskAPI. Given this, we have the first point:

  1. Remove the headers option from fetch request.

Why do that? well, if you look at the FormData documentation we have this quote below:

The FormData interface provides a way to easily construct a set of key/value pairs representing form fields [...] uses the same format a form would use if the encoding type were set to multipart/form-data.

So when using FormData we are automatically using multipart/form-data. But, also in the FormData documentation, we have this warning:

Warn…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@stanmertens
Comment options

@ThiefMaster
Comment options

@stanmertens
Comment options

@stanmertens
Comment options

Comment options

You must be logged in to vote
2 replies
@stanmertens
Comment options

@motts-codes
Comment options

Answer selected by stanmertens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #4900 on December 06, 2022 18:06.