Home › Forums › Front-end Issues › Frontend form file upload validation › Reply To: Frontend form file upload validation
Hi @gregor
I can reproduce it now. It seems that the basic uploader doesn’t check the file type. As a workaround, you can try the following code:
add_filter('acf/validate_value/type=file', 'my_acf_validate_value', 10, 4);
function my_acf_validate_value( $valid, $value, $field, $input ){
// bail early if value is already invalid
if( !$valid ) {
return $valid;
}
// Get the allowed types and store it in an array
$allowed_types = explode(',', trim($field['mime_types']));
// Get the current file extension
$file_extension = pathinfo($value)['extension'];
// Check if the current file extension is allowed or not
if( !in_array($file_extension, $allowed_types) ){
$valid = 'This file type is not allowed';
}
// return
return $valid;
}
If you want, you can also open a new ticket so this issue can be passed directly to the plugin author? You can open a new ticket here: https://support.advancedcustomfields.com/new-ticket.
I hope this helps 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.