[英]How to upload user profile multiple image from frontend in wordpress?
I create my custom registration form plugin at frontend. 我在前端创建我的自定义注册表单插件。 Now I need that user can upload multiple image and save it on user table and also save it on user profile folder. 现在,我需要该用户可以上载多个图像并将其保存在用户表中,还应将其保存在用户配置文件文件夹中。 I use many plugin like Custom User Profile Photo , Metronet Profile Picture but it not work properly. 我使用了许多插件,例如“ 自定义用户个人资料照片” ,“ Metronet个人 资料照片” ,但无法正常工作。 So please suggest me proper way. 所以请建议我正确的方法。
function imageupload($imagename){
$uploadedfile = $imagename;
$upload_overrides = array( 'test_form' => false );
$movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
if ( $movefile && !isset( $movefile['error'] ) )
{
$wp_filetype = $movefile['type'];
$filename = $movefile['file'];
$wp_upload_dir = wp_upload_dir();
$attachment = array(
'guid' => $wp_upload_dir['url'] . '/' . basename( $filename ),
'post_mime_type' => $wp_filetype,
'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
'post_content' => '',
'post_status' => 'inherit'
);
$attach_id = wp_insert_attachment( $attachment, $filename);
$attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
wp_update_attachment_metadata( $attach_id, $attach_data );
}
else
{
echo $movefile['error'];
}
}
$uploadedfile3 = $_FILES['idcard']; /* First image */
imageupload($uploadedfile3);
$uploadedfile1 = $_FILES['Licence']; /*second image*/
imageupload($uploadedfile1);
$uploadedfile2 = $_FILES['Agreement']; /*next image*/
imageupload($uploadedfile2);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.