- Issue created by @Ishani Patel
- Merge request !560Use correct FAPI element to validate uploaded file types on file upload fields. #3519474 → (Open) created by MrDaleSmith
- 🇬🇧United Kingdom MrDaleSmith
It looks like the explorers were using incorrect FAPI elements for the file upload that weren't correctly restricting file type uploads: the element should be restricted only to MP3 for compatibility across the widest range of AI Providers.
I've updated all the explorers and added the help text to the descriptions.
- 🇩🇪Germany marcus_johansson
I tried it out and could still upload "faulty" files and reach the AI Providers error message. As per this link it looks like Drupal only does actual checks on managed_file form elements, which we don't want: https://drupal.stackexchange.com/a/287683
The solution is probably that we add validation manually?
Also the #accept element was wrong, but having accept attribute there is correct, so something like
'#attributes' => [ "accept" => ".jpg, .jpeg, .png", ],
This will make sure that I only see those kind of files in my browser when clikcing on the "Choose File"
- 🇮🇳India prabha1997
I have just added the accept attribute to the file input field to restrict the selectable file types in the file dialog. This improves the user experience by showing only supported formats (.jpg, .jpeg, .png) when choosing a file.
- 🇮🇳India Kanchan Bhogade
Hi
I have tried to reproduce this issue with the provided steps
But I get another error instead of the unsupported file error.Attaching screenshot
- 🇮🇳India prashant.c Dharamshala
Reviewed the MR and left a feedback to be addressed.
Additionally @kanchan bhogade tried to upload a PNG which we is not allowed and should have given a validation message. PNG is also a very common image extension, should we consider allowing it also?
- 🇮🇳India prabha1997
@Prashant
There are two fields:
File field – Only.mp3
files are allowed.
Image field – Accepts.jpg, .jpeg, and .png
formats. - 🇮🇳India prabha1997
I’m currently unable to test the image_and_audio_to_video explorer, as I couldn’t find any provider listed for it in the documentation.