Hey. I make websites on grav. I need to make a form for the user to send a message. With this there is no problem. But I need to do so that the user can attach the file to the message. How to do it ? I use the skeleton receptar.
Please, can anyone help?
Reading the docs?
https://learn.getgrav.org/forms/blueprints/how-to-add-file-upload
Yes, of course) The doektent describes how to upload a file to the server. And it is sometimes really loaded there and saved, for example, in the folder usr / doc. Only for some reason it is not in all selectons.
form:
name: custom_form
fields:
-
name: my-file
label: 'Add a file'
type: file
multiple: false
destination: user/data/files
accept:
- application/pdf
- application/x-pdf
- image/png
- text/plain
process:
-
email:
body: ‘{% include “forms/data.html.twig” %}’
attachments:
- ‘my-file’
I used this snippet to add a file download field to my form. For example, in the skeleton receptar, this field looks like this (screenshot)
The complete form code is specified here
The field in the selection of the file is not active. If you install the control panel plug-in, and in the plugin properties of the form specify not to use the built-in styles, then the “select file” button appears. It certainly is not as graceful as the dropzone, but at least. The file is selected, and when I unpack the message from the form to the e-mail, the file is not attached to the message.
If you enable the debugger, it shows that the value of the file field is empty.
Naturally the letters come without an attached file. The file itself is saved to the folder where the form is located, if you selected @ self or user / data. But as soon as the file
user/config/plugins/email.yaml
Fill in the fields from and to where, the messages stop sending at all. Experienced, I found out that any change to this file causes the messages to stop sending even if you remove the changes and restore the file. Messages are no longer sent.
In some skeletons, messages of the contact form are not sent at all either.
Chitoby exclude a possible error when creating a skeleton, I took the distribution by default. There’s the same thing. The form works only if there is never a modified file user/config/plugins/email.yaml
But the file does not attach to the mail message. As there is somewhere somewhere missing the code that does this.
If I make a mistake somewhere, then I do not see it, can you tell me.