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 {
}
}
我几乎可以肯定这个代码应该可以工作。我环顾四周,人们说,一旦这起作用,就添加require\\u。
上传工作正常,文件已添加到媒体库,但未生成元数据。
有什么建议吗?