bp_attachments_check_filetype

Check the uploaded attachment type is allowed.

Description

bp_attachments_check_filetype( (string) $file, (string) $filename, (array) $allowed_mimes ); 

Parameters (3)

0. $file (string)
Full path to the file.
1. $filename (string)
The name of the file (may differ from $file due to $file being in a tmp directory).
2. $allowed_mimes (array)
The attachment allowed mimes (Required).

Usage

  1. if ( !function_exists( 'bp_attachments_check_filetype' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-attachments.php'; 
  3.  
  4. // Full path to the file. 
  5. $file = ''; 
  6.  
  7. // The name of the file (may differ from $file due to $file being 
  8. // in a tmp directory). 
  9. $filename = ''; 
  10.  
  11. // The attachment allowed mimes (Required). 
  12. $allowed_mimes = array(); 
  13.  
  14. // NOTICE! Understand what this does before running. 
  15. $result = bp_attachments_check_filetype($file, $filename, $allowed_mimes); 
  16.  

Defined (1)

The function is defined in the following location(s).

/bp-core/bp-core-attachments.php  
  1. function bp_attachments_check_filetype( $file, $filename, $allowed_mimes ) { 
  2. $filetype = wp_check_filetype_and_ext( $file, $filename, $allowed_mimes ); 
  3.  
  4. if ( ! empty( $filetype['ext'] ) && ! empty( $filetype['type'] ) ) { 
  5. return true; 
  6.  
  7. return false;