Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(revision 21284)
+++ wp-includes/functions.php	(working copy)
@@ -1595,7 +1595,7 @@
 		return $upload;
 
 	$upload_bits_error = apply_filters( 'wp_upload_bits', array( 'name' => $name, 'bits' => $bits, 'time' => $time ) );
-	if ( !is_array( $upload_bits_error ) ) {
+	if ( ! is_array( $upload_bits_error ) || isset( $upload_bits_error['error'] ) ) {
 		$upload[ 'error' ] = $upload_bits_error;
 		return $upload;
 	}
@@ -1617,7 +1617,7 @@
 	clearstatcache();
 
 	// Set correct file permissions
-	$stat = @ stat( dirname( $new_file ) );
+	$stat  = stat( dirname( $new_file ) );
 	$perms = $stat['mode'] & 0007777;
 	$perms = $perms & 0000666;
 	@ chmod( $new_file, $perms );
@@ -1626,6 +1626,9 @@
 	// Compute the URL
 	$url = $upload['url'] . "/$filename";
 
+	if ( is_multisite() )
+		delete_transient( 'dirsize_cache' );
+
 	return array( 'file' => $new_file, 'url' => $url, 'error' => false );
 }
 
Index: wp-includes/class-wp-xmlrpc-server.php
===================================================================
--- wp-includes/class-wp-xmlrpc-server.php	(revision 21284)
+++ wp-includes/class-wp-xmlrpc-server.php	(working copy)
@@ -4557,6 +4557,7 @@
 		}
 
 		$upload = wp_upload_bits($name, null, $bits);
+
 		if ( ! empty($upload['error']) ) {
 			$errorString = sprintf(__('Could not write file %1$s (%2$s)'), $name, $upload['error']);
 			return new IXR_Error(500, $errorString);
Index: wp-admin/includes/ms.php
===================================================================
--- wp-admin/includes/ms.php	(revision 21284)
+++ wp-admin/includes/ms.php	(working copy)
@@ -19,7 +19,7 @@
 	if ( get_site_option( 'upload_space_check_disabled' ) )
 		return $file;
 
-	if ( $file['error'] != '0' ) // there's already an error
+	if ( $file['error'] && $file['error'] != '0' ) // there's already an error
 		return $file;
 
 	if ( defined( 'WP_IMPORTING' ) )
@@ -28,20 +28,31 @@
 	$space_allowed = 1048576 * get_space_allowed();
 	$space_used = get_dirsize( BLOGUPLOADDIR );
 	$space_left = $space_allowed - $space_used;
-	$file_size = filesize( $file['tmp_name'] );
-	if ( $space_left < $file_size )
+
+	if( 'wp_upload_bits' == current_filter() ) {
+		if( function_exists( 'mb_strlen' ) )
+			$file_size = mb_strlen( $file['bits'], 'ascii');
+		else
+			$file_size = strlen( $file['bits'] );
+	}
+	else {
+		$file_size = filesize( $file['tmp_name'] );
+	}
+
+	if( $space_left < $file_size )
 		$file['error'] = sprintf( __( 'Not enough space to upload. %1$s KB needed.' ), number_format( ($file_size - $space_left) /1024 ) );
-	if ( $file_size > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) )
+	if( $file_size > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) )
 		$file['error'] = sprintf(__('This file is too big. Files must be less than %1$s KB in size.'), get_site_option( 'fileupload_maxk', 1500 ) );
-	if ( upload_is_user_over_quota( false ) ) {
+	if( upload_is_user_over_quota( false ) ) {
 		$file['error'] = __( 'You have used your space quota. Please delete files before uploading.' );
 	}
-	if ( $file['error'] != '0' && !isset($_POST['html-upload']) )
+	if( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && 'wp_handle_upload_prefilter' == current_filter() )
 		wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
 
 	return $file;
 }
 add_filter( 'wp_handle_upload_prefilter', 'check_upload_size' );
+add_filter( 'wp_upload_bits', 'check_upload_size' );
 
 /**
  * Delete a blog
