Validate::file_have_error( object $field )
Description #
Check if a upload field’s value array have error.
Parameters #
- $fieldobject (Required) Instance of @see
AP_Field
object.
Source #
File: lib/class-validate.php
private static function file_have_error( $field ) { $args = $field->get( 'upload_options' ); $value = $field->value(); $errors = array( 0 => __( 'There is no error, the file uploaded with success', 'anspress-question-answer' ), 1 => __( 'The uploaded file exceeds the upload_max_filesize directive in php.ini', 'anspress-question-answer' ), 2 => __( 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', 'anspress-question-answer' ), 3 => __( 'The uploaded file was only partially uploaded', 'anspress-question-answer' ), 4 => __( 'No file was uploaded', 'anspress-question-answer' ), 6 => __( 'Missing a temporary folder', 'anspress-question-answer' ), 7 => __( 'Failed to write file to disk.', 'anspress-question-answer' ), 8 => __( 'A PHP extension stopped the file upload.', 'anspress-question-answer' ), ); $have_error = false; if ( true === $args['multiple'] && wp_is_numeric_array( $value ) ) { foreach ( $value as $key => $file ) { if ( 0 !== $file['error'] ) { $have_error = $errors[ $file['error'] ]; } } } else { if ( 0 !== $value['error'] ) { $have_error = $errors[ $value['error'] ]; } } return $have_error; }
Expand full source code Collapse full source code View on GitHub: lib/class-validate.php:615
Add your comment