Skip to main content
added 3 characters in body
Source Link
Nicolai Grossherr
  • 18.9k
  • 8
  • 64
  • 109

You can restrict the file size via the wp_handle_upload_prefilter, where

The single parameter, $file, represent a single element of the $_FILES array.

The code below is just exemplary and untested, but you'll get the point.

add_filter(
    'wp_handle_upload_prefilter',
    'wpse163236_restrict_upload_file_size'
);
function wpse163236_restrict_upload_file_size( $file ){
    $file_size  = $file[ 'size' ];
    $size_limit = '1024';'1024000';
    if ( $size_limit < $file_size ) {
        $file[ 'error' ] = 'File Size Over: ' . $size_limit;
    }
    return $file;
}

You can restrict the file size via the wp_handle_upload_prefilter, where

The single parameter, $file, represent a single element of the $_FILES array.

The code below is just exemplary and untested, but you'll get the point.

add_filter(
    'wp_handle_upload_prefilter',
    'wpse163236_restrict_upload_file_size'
);
function wpse163236_restrict_upload_file_size( $file ){
    $file_size  = $file[ 'size' ];
    $size_limit = '1024';
    if ( $size_limit < $file_size ) {
        $file[ 'error' ] = 'File Size Over: ' . $size_limit;
    }
    return $file;
}

You can restrict the file size via the wp_handle_upload_prefilter, where

The single parameter, $file, represent a single element of the $_FILES array.

The code below is just exemplary, but you'll get the point.

add_filter(
    'wp_handle_upload_prefilter',
    'wpse163236_restrict_upload_file_size'
);
function wpse163236_restrict_upload_file_size( $file ){
    $file_size  = $file[ 'size' ];
    $size_limit = '1024000';
    if ( $size_limit < $file_size ) {
        $file[ 'error' ] = 'File Size Over: ' . $size_limit;
    }
    return $file;
}
deleted 5 characters in body
Source Link
Nicolai Grossherr
  • 18.9k
  • 8
  • 64
  • 109

You can restrict the file size via the wp_handle_upload_prefilter, where

The single parameter, $file, represent a single element of the $_FILES array.

The code below is just exemplary and untested, but you'll get the point.

add_filter(
    'wp_handle_upload_prefilter',
    'wpse163236_restrict_upload_file_size'
);
function wpse163236_restrict_upload_file_size( $file ){
    $file_size  = $file[ 'size' ];
    $size_limit = '1024';
    if ( $size_limit < $file_size ) {
        $file[ 'error' ] = 'File Size Over: ' . $file_size_limit;$size_limit;
    }
    return $file;
}

You can restrict the file size via the wp_handle_upload_prefilter, where

The single parameter, $file, represent a single element of the $_FILES array.

The code below is just exemplary and untested, but you'll get the point.

add_filter(
    'wp_handle_upload_prefilter',
    'wpse163236_restrict_upload_file_size'
);
function wpse163236_restrict_upload_file_size( $file ){
    $file_size  = $file[ 'size' ];
    $size_limit = '1024';
    if ( $size_limit < $file_size ) {
        $file[ 'error' ] = 'File Size Over: ' . $file_size_limit;
    }
    return $file;
}

You can restrict the file size via the wp_handle_upload_prefilter, where

The single parameter, $file, represent a single element of the $_FILES array.

The code below is just exemplary and untested, but you'll get the point.

add_filter(
    'wp_handle_upload_prefilter',
    'wpse163236_restrict_upload_file_size'
);
function wpse163236_restrict_upload_file_size( $file ){
    $file_size  = $file[ 'size' ];
    $size_limit = '1024';
    if ( $size_limit < $file_size ) {
        $file[ 'error' ] = 'File Size Over: ' . $size_limit;
    }
    return $file;
}
Source Link
Nicolai Grossherr
  • 18.9k
  • 8
  • 64
  • 109

You can restrict the file size via the wp_handle_upload_prefilter, where

The single parameter, $file, represent a single element of the $_FILES array.

The code below is just exemplary and untested, but you'll get the point.

add_filter(
    'wp_handle_upload_prefilter',
    'wpse163236_restrict_upload_file_size'
);
function wpse163236_restrict_upload_file_size( $file ){
    $file_size  = $file[ 'size' ];
    $size_limit = '1024';
    if ( $size_limit < $file_size ) {
        $file[ 'error' ] = 'File Size Over: ' . $file_size_limit;
    }
    return $file;
}