Web3Forms
Search…
File Attachments
Heads Up! This is a PRO feature. You must have an active membership to use this feature.
1
<input type="file" name="attachment" />
Copied!
You will need to add enctype="multipart/form-data" to the Form Element to make the attachment work.
1
<form action="https://api.web3forms.com/submit" enctype="multipart/form-data" method="POST">
2
...
3
<input type="file" name="attachment" />
4
...
5
</form>
Copied!
If you are using Javascript / Ajax to submit the form, make sure you set the Headers accordingly. Setting wrong headers will throw an error.

Here's an example code with Javascript

1
async function submitForm(form) {
2
const formData = new FormData(form);
3
try {
4
const response = await fetch("https://api.web3forms.com/submit", {
5
method: "POST",
6
body: formData
7
});
8
// No need to set headers here
9
// Javascript does that automatically
10
let json = await response.json();
11
this.submitting = false;
12
13
if (response.status == 200) {
14
this.success = true;
15
} else {
16
this.error = true;
17
}
18
} catch (error) {
19
console.log(error);
20
}
21
}
22
23
Copied!
Last modified 6mo ago
Copy link