You’re doing it twice – media_handle_upload
is a wrapper for wp_handle_upload
.
Just use the former like so:
require_once ABSPATH . 'wp-admin/includes/file.php';
$id = media_handle_upload(
'custom_upload',
$post->ID,
array(), // Attachment post data overrides, WordPress will do all the grunt work by default
array(
'test_form' => false,
'action' => 'editpost',
)
);
if ( ! is_wp_error( $id ) )
update_post_meta( $post->ID, 'custom_upload', $id );