Stl MIME type validation problem

Hello,

I’m trying to allow STL file uploads in a Bricksforge Pro Form, but files are being rejected with the error “Some uploaded files were rejected due to security validation.”

What I’ve tried:

  1. Added application/octet-stream to the “Allowed file types” field in the form settings
  2. Used the bricksforge/pro_forms/allowed_file_types filter in functions.php:
add_filter( 'bricksforge/pro_forms/allowed_file_types', function( $allowed_file_types ) {
    $allowed_file_types[] = 'application/octet-stream';
    return $allowed_file_types;
} );
  1. Added WordPress MIME type filters:
add_filter( 'upload_mimes', function( $mimes ) {
    $mimes['stl'] = 'application/octet-stream';
    return $mimes;
} );

Additional information:

  • STL files upload successfully to WordPress Media Library (confirmed MIME type: application/octet-stream)
  • The form field accepts other file types (PDF, images) without issues
  • No cache plugins active, browser cache cleared

When i have this setting, it validates the form, but file is not uploaded to custom folder, but to bricksforge/tmp. When custom path option is not toggled, it throws an error.

Question:

How can I properly configure Pro Forms to accept STL files with MIME type application/octet-stream? Is there an additional security setting or filter I’m missing?

Screenshots attached showing mime type and error message.

Thank you for your help!


Can you try it with the current BETA version?

It works with BETA, thank you.

How should this filter work? I understood only the MIME types listed in the code should be allowed, but I can upload any standard file.

add_filter( 'bricksforge/pro_forms/allowed_file_types', function( $allowed_file_types ) {
    $allowed_file_types[] = 'application/octet-stream';
    $allowed_file_types[] = 'application/pdf';
    $allowed_file_types[] = 'image/png';
    $allowed_file_types[] = 'image/jpeg';
    $allowed_file_types[] = 'image/jpg';
    return $allowed_file_types;
} );

When tried to allow the same MIME types in proform settings, application/octet-stream does not work.

Thank you.

On server side, standard files are automatically allowed. In your code, you are just adding more element to the already existing array. If you want to replace the array, you need to replace it in the code :slight_smile:

1 Like