File uploads
Let Visitors attach Files to a Submission, with a plain HTML form for small Files or the drop-in script for larger ones.
A Form accepts Files without any setting. Add file inputs to the form and the Files arrive with the Submission. How you send them decides the size limit.
With a plain HTML form
Set enctype="multipart/form-data" on the form and add file inputs:
<form
action="https://us.insaneforms.com/f/<form-id>"
method="POST"
enctype="multipart/form-data"
>
<input name="email" type="email">
<input name="resume" type="file">
<button>Send</button>
</form>The whole request, fields and Files together, can be about 4 MB (4,194,304 bytes). A larger request gets 413 and "Body too large". A single File over the Workspace's upload limit gets 413 and "File too large".
An empty file input is ignored. A form that has only a File and no other field is accepted.
With the drop-in script
For Files larger than about 4 MB, use the drop-in script or @insane-forms/core. Before it sends the form, the script uploads each File straight to storage. It then posts the fields with a _files field that lists the uploaded Files. The Files do not pass through the form request, so each can be as large as the Workspace's upload limit.
Nothing changes in the markup beyond the script and the data-insane-forms attribute:
<script src="https://us.insaneforms.com/v1.js" defer></script>
<form
action="https://us.insaneforms.com/f/<form-id>"
method="POST"
data-insane-forms
>
<input name="resume" type="file">
<button>Send</button>
<p data-insane-forms-error></p>
</form>How it works, for when you need to debug it:
- For each File, the script posts the file name and size to
https://us.insaneforms.com/f/<form-id>/upload. The answer holds a storage path and a short-lived upload token, valid for 10 minutes. - The script uploads the File to storage with that token. Files over 8 MB are sent in parts.
- It posts the form to the endpoint with
_files, a JSON list of{ fieldName, pathname }. - The endpoint checks that each upload exists, belongs to this Form and is under an hour old, and then attaches it. A File uploaded more than an hour before the form was sent is rejected with "Upload expired. Please upload the file again."
For a direct upload, characters other than letters, digits, ., _ and - in the File name become _, so my résumé.pdf is stored as my_r_sum_.pdf. A File sent in a plain form post keeps its original name.
Limits
- Up to 10 Files per Submission.
- Each File up to the Workspace's upload limit, 10 MB by default.
- Up to 20 Files per sender and 200 per Workspace in 10 minutes. Files sent in a plain form post count too. Past that, the request gets
429and "Too many uploads. Try again in a few minutes." - If one File in a Submission fails, the whole Submission is refused and nothing is stored. A reference to an upload that was used before gets "Upload expired. Please upload the file again."
See Limits.
Read the Files
Each File is listed with its Submission under the name of the input that sent it. Downloading needs a signed-in person with access, or a Studio reader. See Files.