I need to force wp_handle_upload to overwrite a file with the same name as the one being uploaded:
this is my current code:
if ( ! function_exists( 'wp_handle_upload' ) ) require_once( ABSPATH . 'wp-admin/includes/file.php' );
$uploadedfile = $_FILES['myfile'];
$new_filename="amine";
$upload_overrides = array( 'test_form' => false );
$movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
i think you can force overwrite the existing file with the same name by adding custom
wp_unique_filename
callback, pass it on$upload_overrides
args like thisuse unlink($filePath) first to delete the file that is already there and then you can execute the upload.