[FREE]HttpUtil - Post a html form with enctype set to multipart/form-data

Why this extension:
The build-in Web component is missing a function to post html form with enctype set to multipart/form-data, this extension just does that.
Now no need to open a webviewer and run javascript any more.

All blocks:
image

Download link:
[link removed for bug fixing]

Example:

let's surpose we have a HTML form like:

<form action="submit.php" method="post" enctype="multipart/form-data">
  Name: <input type="text" name="username"><br>
  File: <input type="file" name="filename"><br>
  <input type="submit" value="Submit">
</form>

we can post this form like :

Credit:
original java code from here

====
Any feedback is welcomed.

13 Likes

@Kevinkun It functions well with HTML forms, but what about sending requests directly to an API URL? When I try using the API URL, I receive an error indicating that the
request Content-Type is not set to multipart/form-data.
Is this possible?

possible to tell us the api document?
did you set the content type in headers?

error in file


remove file: /

I did it


and show other error

can you upload an example

image

It's pocketbase, you can also try demo below which had API preview,

Yes I tried setting in headers too but it doesn't work,URL hidden only here

I'm doing the same thing and it doesn't work,I'm going to see what, I send to see

Try with Image Picker component,
Directly insert the Image Picker selection in files input,
It works fine

nothing, same


error Broken pipe

feed fields with empty list?

so what's inside global image_file?

https://community.appinventor.mit.edu/uploads/default/original/3X/6/1/61c8e0ea881ea39725cdfd4a223359dca8cbf4b5.png
It's an image, which uploads fine in HTML form.

image
right click this one, and run "DO IT"

so with ImagePicker.Selection it is working, but with global image_file, it's not working? what's the error message? upload the aia?

uploadtest.aia (16.1 KB)
Here's the AIA.
I have DM you the DB URL

ERROR Msg,

request Content-Type isn't multipart/form-data

DB Log:

{
  "id": "4ytjnu2zqmgi022",
  "created": "2024-10-11 01:45:42.643Z",
  "data": {
    "auth": "",
    "details": "request Content-Type isn't multipart/form-data",
    "error": "Something went wrong while processing your request.",
    "execTime": 0.056214,
    "method": "POST",
    "referer": "",
    "status": 400,
    "type": "request",
    "url": "/api/collections/test/records",
  },
  "message": "POST /api/collections/test/records",
  "level": 8
}