I can't upload a jpg or png image using input media
pcarantes opened this issue · 4 comments
Hello, my form has two fields for uploading files, one being a PDF and the other a PNG or JPG.
After making all the settings, the form works correctly to upload a pdf file.
However, the form presents a validation error when I configure the field to collect the user's image.
This is the error that appears in Form records:
Exception: Jet_Form_Builder\Request\Exceptions\Sanitize_Value_Exception
Message: has_errors
Error Place: plugins/jetformbuilder/modules/block-parsers/module.php:134
Data: [
{
"cartaz_do_evento": [
"upload_mime_types",
"empty_field"
]
}
]
This is the link to my form:
https://contep.genuinne.com.br/cadastro-de-prova/
For the two input fields: PDF and Image png or jpg, it is configured in: User access - Any Users
I used ACF to configure both fields.
Can you help me with this?
Hi @pcarantes
Do you check the MIME types for the media field https://i.imgur.com/4UM0oDq.png?
Yes, I selected an option. And the error persists.
In subimitions action, I have configured:
Edit Insert/Update Post
And the field is mapped to save the image in I map this field to save in Post Thumbnail. When I choose to save in a Gallery type field, the error does not appear, the file is saved in /uploads/jet-form-builder but is not loaded in the custom post registration.
As for the field that receives the PDF, everything runs normally.
Another condition I tested was:
In subimitions action, I have configured:
Send Email, and I configured the two file fields to add to the form with attachment.
And if the png or jpg image field is mapped to be added to a gallery-type field, the two files are correctly attached to the recipient's message.
I believe this is a bug, when the access condition is: Any user (incl. Gest)
Hello, I just did a new test where I kept all the settings mentioned in previous messages, and with a logged in user. Submit the registration of a new record. And the image was saved correctly as the custom post's featured image.
I believe there is a bug where it is not allowed to record png, jpg images as the post's featured image when I use the feature to submit a new post on the Wordpress frontend. Even if the access condition is: Any user (including Gest)
Hi @pcarantes
If you need the images that were uploaded by guest users to go to the Media Library, follow this way:
-
Add the 'allow-insert-attachments' custom class to the Media field https://prnt.sc/QEedIUCLHqWq
You may add a class with a format, like this:
allow-insert-attachments-id
- if the Media field format is Media ID https://prnt.sc/qZZyIfxaXYdh
allow-insert-attachments-url
- if the Media field format is Media URL https://prnt.sc/XhfA8bYgMiCC
allow-insert-attachments-both
- if the Media field format is Array with Media ID and URL https://prnt.sc/fUAeNHgA13DM
If you set no format, it will be set to 'id' -
Then add the code below to the Code Snippets plugin or to the functions.php file of your current theme.
https://gist.github.com/Crocoblock/d4900630b15f548b6be13e8a61960db6
The code works on 3.0.4 + versions only! -
Configure the Media field: https://prnt.sc/-9_oIOeudD67
You can watch a video tutorial for guidance:
https://youtu.be/ZKs7AT1Vpp4
Please be aware that restricting uploads for non-logged-in users is a security measure, so you should avoid allowing them when possible.