Skip to content

Instantly share code, notes, and snippets.

@Konark-Web
Created September 23, 2020 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Konark-Web/8e93dc56c17dbd450148f349c0b4321f to your computer and use it in GitHub Desktop.
Save Konark-Web/8e93dc56c17dbd450148f349c0b4321f to your computer and use it in GitHub Desktop.
if( wp_verify_nonce( $_POST['fileup_nonce'], 'my_file_upload' ) ){
if ( ! function_exists( 'wp_handle_upload' ) ) {
require_once( ABSPATH . 'wp-admin/includes/file.php' );
}
// require_once( ABSPATH . 'wp-admin/includes/image.php' );
// require_once( ABSPATH . 'wp-admin/includes/file.php' );
// require_once( ABSPATH . 'wp-admin/includes/media.php' );
$file = & $_FILES['my_file_upload'];
$overrides = [ 'test_form' => false ];
$movefile = wp_handle_upload( $file, $overrides );
// $attachment_id = media_handle_upload( 'my_file_upload', '0' );
if ( $movefile['error'] ) {
update_user_meta( $customer_id, 'uploaded_file', $movefile['error'] );
}
if ( $movefile && empty( $movefile['error'] ) ) {
update_user_meta( $customer_id, 'uploaded_file', $movefile['url'] );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment