}
if ( $_POST ) {
- $location = 'upload.php';
if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
check_admin_referer('media-form');
// Upload File button was clicked
- $id = media_handle_upload( 'async-upload', $post_id );
- if ( is_wp_error( $id ) )
- $location .= '?message=3';
+ $upload_id = media_handle_upload( 'async-upload', $post_id );
+ if ( is_wp_error( $upload_id ) ) {
+ wp_die( $upload_id );
+ }
}
- wp_redirect( admin_url( $location ) );
+ wp_redirect( admin_url( 'upload.php' ) );
exit;
}