您好,我有一个带有文件上传的前端表单,在提交 wp_redirect 之后,header() 也没有工作。
<?php if( 'POST' == $_SERVER['REQUEST_METHOD'] ) { // if form has been submitted
update_field('field_2', $title, $postID);
update_field('field_3', $efternamn, $postID);
update_field('field_4', $epost, $postID);
update_field('field_6', $telefon, $postID);
update_field('field_7', $motiv, $postID);
if (!function_exists('wp_generate_attachment_metadata')){
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
}
if ($_FILES) {
foreach ($_FILES as $file => $array) {
if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) {
return "upload error : " . $_FILES[$file]['error'];
}
$attach_id = media_handle_upload( $file, $postID );
}
}
//if ($attach_id > 0){
//and if you want to set that image as Post then use:
//update_post_meta($postID,'_thumbnail_id',$attach_id);
//}
update_field('field_5', $attach_id, $postID);
$dialog_url='http://tatchit.com';
wp_redirect(home_url());
}
?>
有什么建议么?