How to nest upload_file in button?

I’m running a simple code locally.

import streamlit as st
import pandas as pd
import numpy as np
import os
import shutil

opt_select = st.selectbox(
    "Please select from one of the options",
    ("Abs", "Bgf")

if opt_select == "Abs":
    if st.button("Submit"):
        st.write("New created.")
        uploaded_file = st.file_uploader("Upload text file", type=["txt"])
        if uploaded_file is not None:

            st.warning("No Selection")

I want to have a file upload widget pop up after clicking a button.
Currently when i am trying to upload a file it dissapears right after i upload it…
File_uploader works fine when it is outside the opt_select loop.

You will need to keep track of the button click using a session_state because buttons do not keep their state between interactions. This is covered in explanation #1 in