Make WordPress Core

Ticket #16820: 16820.diff

File 16820.diff, 1020 bytes (added by solarissmoke, 14 years ago)

With browser uploader, don't redirect back to media library and instead tell the user what went wrong.

  • wp-admin/media-upload.php

     
    3535        wp_die(__("You are not allowed to be here"));
    3636
    3737if ( isset($_GET['inline']) ) {
    38         $errors = array();
    39 
    4038        if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
    4139                // Upload File button was clicked
    4240                $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
    4341                unset($_FILES);
    44                 if ( is_wp_error($id) ) {
    45                         $errors['upload_error'] = $id;
    46                         $id = false;
    47                 }
     42                if ( is_wp_error($id) )
     43                        wp_die( $id );
    4844        }
    4945
    5046        if ( isset($_GET['upload-page-form']) ) {
    51                 $errors = array_merge($errors, (array) media_upload_form_handler());
    52 
    53                 $location = 'upload.php';
     47                $errors = (array) media_upload_form_handler();
    5448                if ( $errors )
    55                         $location .= '?message=3';
    56 
    57                 wp_redirect( admin_url($location) );
    58                 exit;
     49                        wp_die( implode(' ', $errors) );
    5950        }
    6051
    6152        $title = __('Upload New Media');