Skip to content

Commit ac1539b

Browse files
authored
Merge pull request #300 from WPUserManager/upload-fix
Upload fix
2 parents a756434 + 2394f2e commit ac1539b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

includes/functions.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,8 @@ function wpum_send_registration_admin_email( $user ) {
502502
* Prepare file information for upload.
503503
*
504504
* @param array $file_data
505-
* @return void
505+
*
506+
* @return array
506507
*/
507508
function wpum_prepare_uploaded_files( $file_data ) {
508509
$files_to_upload = array();
@@ -524,6 +525,7 @@ function wpum_prepare_uploaded_files( $file_data ) {
524525
$file_data['type'] = $type['type'];
525526
$files_to_upload[] = $file_data;
526527
}
528+
527529
return apply_filters( 'wpum_prepare_uploaded_files', $files_to_upload );
528530
}
529531

@@ -561,6 +563,11 @@ function wpum_upload_file( $file, $args = array() ) {
561563
return $file;
562564
}
563565

566+
$check = wp_check_filetype_and_ext( $file['tmp_name'], $file['name'] );
567+
if ( ! $check['ext'] || ! $check['type'] ) {
568+
return new WP_Error( 'upload', __( 'Sorry, you are not allowed to upload this file type.' ) );
569+
}
570+
564571
if ( ! in_array( $file['type'], $allowed_mime_types ) ) {
565572
if ( $args['file_label'] ) {
566573
return new WP_Error( 'upload', sprintf( __( '"%1$s" (filetype %2$s) needs to be one of the following file types: %3$s', 'wp-user-manager' ), $args['file_label'], $file['type'], implode( ', ', array_keys( $allowed_mime_types ) ) ) );

0 commit comments

Comments
 (0)