Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/01/2008 08:35:54 PM (18 years ago)
Author:
apeatling
Message:

Added more friendly avatar upload feedback.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-avatars.php

    r363 r369  
    7373// Main UI Rendering
    7474function bp_core_avatar_admin( $message = null, $action = null, $delete_action = null ) {
     75        global $wp_upload_error;
    7576        ?>     
    7677        <?php if ( !isset($_POST['slick_avatars_action']) && !isset($_GET['slick_avatars_action']) ) { ?>
    … …  
    117118                        bp_core_ap_die( 'Security error.' );
    118119               
     120                // Set friendly error feedback.
     121                $uploadErrors = array(
     122                        0 => __("There is no error, the file uploaded with success"),
     123                        1 => __("The uploaded file exceeds the upload_max_filesize directive in php.ini"),
     124                        2 => __("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"),
     125                        3 => __("The uploaded file was only partially uploaded"),
     126                        4 => __("No file was uploaded"),
     127                        6 => __("Missing a temporary folder")
     128                );
     129
    119130                if ( !bp_core_check_avatar_upload($_FILES) )
    120                         bp_core_ap_die( 'Your upload failed, please try again.' );
     131                        bp_core_ap_die( 'Your upload failed, please try again. Error was: ' . $uploadErrors[$_FILES['file']['error']] );
    121132               
    122133                if ( !bp_core_check_avatar_size($_FILES) )
    … …  
    128139                // "Handle" upload into temporary location
    129140                if ( !$original = bp_core_handle_avatar_upload($_FILES) )
    130                         bp_core_ap_die( 'Upload Failed! Your image is likely too big.' );
     141                        bp_core_ap_die( 'Upload Failed! Error was: ' . $wp_upload_error );
    131142               
    132143                if ( !bp_core_check_avatar_dimensions($original) )
    … …  
    210221
    211222function bp_core_handle_avatar_upload($file) {
     223        global $wp_upload_error;
     224       
    212225        $res = wp_handle_upload( $file['file'], array('action'=>'slick_avatars') );
    213226        if ( !in_array('error', array_keys($res) ) ) {
    214227                return $res['file'];
    215228        } else {
     229                $wp_upload_error = $res['error'];
    216230                return false;
    217231        }
Note: See TracChangeset for help on using the changeset viewer.