is_wp_error() function give you authority to find error in media upload. Please see below example:

if ( is_wp_error( $attachment_id ) ) {
$errors = $attachment_id->get_error_messages();
foreach( $errors as $error ){
echo $error;
echo ‘There was an error uploading the image’;


Please login or Register to submit your answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.