Form files: the visitor is told when the problem is the file — why and what to do; UTF-8 file names
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
b6f9f34705
commit
97202ee03e
+26
-10
@@ -211,7 +211,7 @@ ipalKit({ forms: { attachments: true } }) // adds the File field to the form
|
||||
**Verify:** submit the form with a PDF → the confirmation shows; the company e-mail has the file attached and the
|
||||
line "…was not checked for viruses"; the confirmation e-mail to the visitor has no file; Form Submissions shows
|
||||
**Files** (name, type, size) and **File delivery: Handed to the mail server**. Rename a `.exe` to `.pdf` and submit →
|
||||
the field shows "…is not an accepted file type", nothing is stored or sent.
|
||||
the File field shows "The file … was refused: …", nothing is stored or sent.
|
||||
|
||||
### Options (`FormAttachmentsOption`)
|
||||
|
||||
@@ -294,8 +294,9 @@ characters, the extension of the detected type (`CV Jan Kowalski.pdf`; an empty
|
||||
|
||||
The file is not kept, so there is nothing to retry with. Then:
|
||||
|
||||
- the **visitor** sees an error — Form messages → **File not sent** ("We could not send your file. Try again, or
|
||||
send it by e-mail.") — keeps their answers and the selected file, and can try again. No confirmation e-mail goes out;
|
||||
- the **visitor** sees an error **at the File field** — Form messages → **File not sent** ("We could not send the
|
||||
file "cv.pdf". Choose a smaller file or another format and try again.") — keeps their answers and the selected
|
||||
file, and can try again. The mail server's own words never reach the visitor. No confirmation e-mail goes out;
|
||||
- **staff** get the notification once more **without** the file: "The visitor attached a file: … but it could not
|
||||
be sent. Ask them to send it again.";
|
||||
- the **submission** is stored and marked **File delivery: Not sent**, with a note (the mail server's reason). The
|
||||
@@ -308,12 +309,27 @@ refuses it) cannot be seen by the site; it arrives in the sender mailbox.
|
||||
(double click, a resend by the browser or a proxy) gets the first answer and sends nothing again. The plugin sends
|
||||
each e-mail once — there is no automatic resend.
|
||||
|
||||
### Result codes and messages
|
||||
### What the visitor is told
|
||||
|
||||
`reason: 'validation'` with `kind: 'file_too_large' | 'file_type' | 'file_count'` (+ `field`, `label`, `file`,
|
||||
`max`, `types`), `kind: 'required'` for a required File field without a file, and `reason: 'delivery'` when the
|
||||
e-mail could not be sent. Texts: Form messages → **Files** (`fileTooLarge`, `fileType`, `fileCount`, `fileNotSent`,
|
||||
`fileRemove`), defaults in English and Polish, per language in the panel ([notifications.md](./notifications.md)).
|
||||
**When a submission fails because of the file, the message says it is the file, why, and what to do** — and it
|
||||
shows at the File field (the result carries `field`). Everything the visitor typed stays in the form.
|
||||
|
||||
| Problem | Code | Text (Form messages → Files) | English default |
|
||||
|---|---|---|---|
|
||||
| too large | `kind: 'file_too_large'` (`file`, `max`) | `fileTooLarge` | The file "cv.pdf" is too large. Choose a file of up to 10 MB. |
|
||||
| a format the field does not take | `kind: 'file_type'` (`file`, `types`) | `fileType` | The file "cv.txt" is in a format we do not accept. Choose one of: PDF, DOC, DOCX. |
|
||||
| refused: a program, an archive, macros, a doubled extension, content that does not match the type, the scanner said no | `kind: 'file_refused'` (`file`, `types`) | `fileRefused` | The file "cv.docx" was refused: it is a program or an archive, it holds macros, or its content does not match its type. Choose another file (PDF, DOC, DOCX). |
|
||||
| too many files | `kind: 'file_count'` (`max`) | `fileCount` | Too many files in "Attachment". Remove some: the limit is 1. |
|
||||
| the e-mail with the file could not be sent | `reason: 'delivery'` (`field`, `file`) | `fileNotSent` | We could not send the file "cv.pdf". Choose a smaller file or another format and try again. |
|
||||
|
||||
- On a File field that is **not required**, every one of these ends with `fileOptional` — "You can also send the
|
||||
form without the file." (the result carries `optional: true`).
|
||||
- A required File field left empty is `kind: 'required'` → the ordinary field text ("Check the field …").
|
||||
- A failure that is **not** about the file keeps its own text: consent, a field error, the rate limit, the
|
||||
general error.
|
||||
- The texts are in the panel like every form message: Form messages → **Files**, per language, with English and
|
||||
Polish defaults — fill the other languages of the site ([notifications.md](./notifications.md)). The browser
|
||||
shows the size, format and count messages before anything is sent; the server answers with the same texts.
|
||||
|
||||
### Your own markup
|
||||
|
||||
@@ -556,8 +572,8 @@ type SubmitFormResult =
|
||||
| { success: true; submissionId: string | number }
|
||||
| { success: false; reason: 'rate_limited' }
|
||||
| { success: false; reason: 'turnstile' }
|
||||
| { success: false; reason: 'validation'; field?: string; kind?: 'invalid_format' | 'required' | 'too_long' | 'unknown_fields' | 'file_too_large' | 'file_type' | 'file_count'; file?: string; max?: number; types?: string }
|
||||
| { success: false; reason: 'delivery'; submissionId?: string | number } // the file could not be e-mailed
|
||||
| { success: false; reason: 'validation'; field?: string; kind?: 'invalid_format' | 'required' | 'too_long' | 'unknown_fields' | 'file_too_large' | 'file_type' | 'file_refused' | 'file_count'; file?: string; max?: number; types?: string; optional?: boolean }
|
||||
| { success: false; reason: 'delivery'; field?: string; file?: string; optional?: boolean; submissionId?: string | number } // the file could not be e-mailed
|
||||
| { success: false; reason: 'not_found' }
|
||||
| { success: false; reason: 'consent'; field?: string }
|
||||
| { success: false; reason: 'error' }
|
||||
|
||||
Reference in New Issue
Block a user