Created
July 19, 2016 16:44
-
-
Save stevenspads/410706d076a6dbe6d5fd5cdc5871be65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$errors = array(); | |
if(isset($_FILES)) | |
{ | |
foreach($_FILES as $file) | |
{ | |
if($file['error'] == 0) | |
{ | |
$file_type = wp_check_filetype(basename($file['name'])); | |
$uploaded_file_type = $file_type['type']; | |
$allowed_file_types = array('image/jpg','image/jpeg','image/png'); | |
if(! in_array($uploaded_file_type, $allowed_file_types)) | |
{ | |
$errors[count($errors)] = __('Please upload JPEG or PNG file types only', TXT_DOMAIN); | |
break; | |
} | |
} | |
else if($file['error'] == 1 || $file['error'] == 2) | |
{ | |
$errors[count($errors)] = __('File sizes must be less than ...'); | |
break; | |
} | |
else if($file['error'] == 3) | |
{ | |
$errors[count($errors)] = __('An uploaded file was only partially loaded'); | |
break; | |
} | |
else if($file['error'] == 6) | |
{ | |
$errors[count($errors)] = __('File upload is missing a temporary folder'); | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment