Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




check_upload_size [ WordPress Function ]

check_upload_size ( $file )
Parameters:
  • (array) $file $_FILES array for a given file.
Returns:
  • (array) $_FILES array with 'error' key set if file exceeds quota. 'error' is empty otherwise.
Defined at:



Determine if uploaded file exceeds space quota.

Source


<?php
function check_upload_size$file ) {
    if ( 
get_site_option'upload_space_check_disabled' ) )
        return 
$file;

    if ( 
$file['error'] != '0' // there's already an error
        
return $file;

    if ( 
defined'WP_IMPORTING' ) )
        return 
$file;

    
$space_allowed 1048576 get_space_allowed();
    
$space_used get_dirsizeBLOGUPLOADDIR );
    
$space_left $space_allowed $space_used;
    
$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 ) ) )
        
$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_quotafalse ) ) {
        
$file['error'] = __'You have used your space quota. Please delete files before uploading.' );
    }
    if ( 
$file['error'] != '0' && !isset($_POST['html-upload']) )
        
wp_die$file['error'] . ' <a href="javascript:history.go(-1)">' __'Back' ) . '</a>' );

    return 
$file;
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

Gebruikersdiscussies [ wordpress.org ]

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics