diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php index 4c42c5be3e..fe05085dd8 100644 --- a/src/wp-admin/includes/file.php +++ b/src/wp-admin/includes/file.php @@ -778,6 +778,12 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) { return call_user_func_array( $upload_error_handler, array( &$file, $upload_error_strings[ $file['error'] ] ) ); } + // A properly uploaded file will pass this test. There should be no reason to override this one. + $test_uploaded_file = 'wp_handle_upload' === $action ? @ is_uploaded_file( $file['tmp_name'] ) : @ is_readable( $file['tmp_name'] ); + if ( ! $test_uploaded_file ) { + return call_user_func_array( $upload_error_handler, array( &$file, __( 'Specified file failed upload test.' ) ) ); + } + $test_file_size = 'wp_handle_upload' === $action ? $file['size'] : filesize( $file['tmp_name'] ); // A non-empty file will pass this test. if ( $test_size && ! ( $test_file_size > 0 ) ) { @@ -789,12 +795,6 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) { return call_user_func_array( $upload_error_handler, array( &$file, $error_msg ) ); } - // A properly uploaded file will pass this test. There should be no reason to override this one. - $test_uploaded_file = 'wp_handle_upload' === $action ? @ is_uploaded_file( $file['tmp_name'] ) : @ is_file( $file['tmp_name'] ); - if ( ! $test_uploaded_file ) { - return call_user_func_array( $upload_error_handler, array( &$file, __( 'Specified file failed upload test.' ) ) ); - } - // A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter. if ( $test_type ) { $wp_filetype = wp_check_filetype_and_ext( $file['tmp_name'], $file['name'], $mimes );