Validate::file_size_error( object $field )

Description #

Check if upload field file size is greater then allowed.

Parameters #

  • $field
    object (Required) Instance of @see AP_Field object.

Source #

File: lib/class-validate.php

	private static function file_size_error( $field ) {
		$args       = $field->get( 'upload_options' );
		$value      = $field->value();
		$have_error = false;
		$is_numeric = wp_is_numeric_array( $value );

		if ( true === $args['multiple'] && $is_numeric ) {
			foreach ( $value as $key => $file ) {
				if ( $file['size'] > ap_opt( 'max_upload_size' ) ) {
					$have_error = true;
				}
			}
		} elseif ( ! $is_numeric && $value['size'] > ap_opt( 'max_upload_size' ) ) {
			$have_error = true;
		}

		return $have_error;
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment