Definition:
function get_upload_space_available() {}
Determines if there is any upload space left in the current blog’s quota.
Return values
returns:of upload space available in bytes
Source code
function get_upload_space_available() {
$space_allowed = get_space_allowed() * 1024 * 1024;
if ( get_site_option( 'upload_space_check_disabled' ) )
return $space_allowed;
$dir_name = trailingslashit( BLOGUPLOADDIR );
if ( !( is_dir( $dir_name) && is_readable( $dir_name ) ) )
return $space_allowed;
$dir = dir( $dir_name );
$size = 0;
while ( $file = $dir->read() ) {
if ( $file != '.' && $file != '..' ) {
if ( is_dir( $dir_name . $file) ) {
$size += get_dirsize( $dir_name . $file );
} else {
$size += filesize( $dir_name . $file );
}
}
}
$dir->close();
if ( ( $space_allowed - $size ) <= 0 )
return 0;
return $space_allowed - $size;
}
1875

February 12, 2011 


No comments yet... Be the first to leave a reply!