foreach ($_FILES as $key => $file) {
$uploadedImage = wp_handle_upload($_FILES[$key], $upload_overrides);
pre_r($uploadedImage);
if (!isset($uploadedImage['error'])) {
$attachID = wp_insert_attachment($uploadedImage, $uploadedImage['file']);
require_once(ABSPATH . 'wp-admin/includes/image.php');
$attach_data = wp_generate_attachment_metadata( $attachID, $uploadedImage['file'] );
print_r($attach_data);
wp_update_attachment_metadata( $attachID, $attach_data );
} else {
}
}
Im almost positive this code should work. I have looked around and people were saying once the added the require_once this worked.
The upload works, the file is added to the media library but no metadata is generated.
Any suggestions?