title: Python Dash - How to take in the Input of Dropdown and Uploaded file for the Submit button
body: <pre><code>    html.H1(children='RailTec Dashboard'),
      #Uploading the files to the board. We want to make sure that two files can be uploaded, read, and grab the same categories to the direct coorelated category.
      #For choosing files between tabs
      html.Div(
      [
          html.H2(&quot;Upload&quot;),
          dcc.Upload(
              id=&quot;upload-data&quot;,
              children=html.Div(
                  [&quot;Drag and drop or click to select a file to upload.&quot;]
              ),
              style={
                  &quot;width&quot;: &quot;100%&quot;,
                  &quot;height&quot;: &quot;60px&quot;,
                  &quot;lineHeight&quot;: &quot;60px&quot;,
                  &quot;borderWidth&quot;: &quot;1px&quot;,
                  &quot;borderStyle&quot;: &quot;dashed&quot;,
                  &quot;borderRadius&quot;: &quot;5px&quot;,
                  &quot;textAlign&quot;: &quot;center&quot;,
                  &quot;margin&quot;: &quot;10px&quot;,
              },
              multiple=True,
          ),
          html.H2(&quot;File List&quot;),
          html.Ul(id=&quot;file-list&quot;),
      ],
      style={&quot;max-width&quot;: &quot;500px&quot;},
      ),
      #Drop Down Menu for the categories. 
      dcc.Dropdown(
          id = 'Categories',
          options=[
              {'label': 'Spikes', 'value': 'Spikes'},
              {'label': 'Fasteners', 'value': 'Fasteners'},
              {'label': 'Ballast Level', 'value': 'Ballast Level'},
              {'label': 'Spikes Med', 'value': 'Spikes'},
              {'label': 'Fasteners Med', 'value': 'Fasteners'},
              {'label': 'Ballast Level Med', 'value': 'Ballast Level'},
              {'label': 'Spikes Bad', 'value': 'Spikes'},
              {'label': 'Fasteners Bad', 'value': 'Fasteners'},
              {'label': 'Ballast Level Bad', 'value': 'Ballast Level'}
          ],
          placeholder=&quot;Select a category&quot;,
          value = 'Select'
      ),
      html.Div(id='dd-output-container'),
  
      html.Form([
      #Enter button Event to trigger app callback for dropdown and upload data to submit what to calculate.
      html.Div(id='target'),
      html.Button('Submit',id='submit', n_clicks=0),
      ], action = '/post', method='post')
  
  
      ])
  
  
  #Uploading file definitions
  def save_file(name, content):
      &quot;&quot;&quot;Decode and store a file uploaded with Plotly Dash.&quot;&quot;&quot;
      data = content.encode(&quot;utf8&quot;).split(b&quot;;base64,&quot;)[1]
      with open(os.path.join(UPLOAD_DIRECTORY, name), &quot;wb&quot;) as fp:
          fp.write(base64.decodebytes(data))
  def uploaded_files():
      &quot;&quot;&quot;List the files in the upload directory.&quot;&quot;&quot;
      files = []
      for filename in os.listdir(UPLOAD_DIRECTORY):
          path = os.path.join(UPLOAD_DIRECTORY, filename)
          if os.path.isfile(path):
              files.append(filename)
      return files
  def file_download_link(filename):
      &quot;&quot;&quot;Create a Plotly Dash 'A' element that downloads a file from the app.&quot;&quot;&quot;
      location = &quot;/download/{}&quot;.format(urlquote(filename))
      return html.A(filename, href=location)
      
  @app.callback(
  Output(&quot;file-list&quot;, &quot;children&quot;),
  [Input(&quot;upload-data&quot;, &quot;filename&quot;), Input(&quot;upload-data&quot;, &quot;contents&quot;)],)
  
  def update_output(uploaded_filenames, uploaded_file_contents):
      &quot;&quot;&quot;Save uploaded files and regenerate the file list.&quot;&quot;&quot;
  
      if uploaded_filenames is not None and uploaded_file_contents is not None:
          for name, data in zip(uploaded_filenames, uploaded_file_contents):
              save_file(name, data)
  
      files = uploaded_files()
      if len(files) == 0:
          return [html.Li(&quot;No files yet!&quot;)]
      else:
          return [html.Li(file_download_link(filename)) for filename in files]
  
  #Callback for dropdown menu
  @app.callback(dash.dependencies.Output('dd-output-container', 'children'),[dash.dependencies.Input('Categories', 'value')])
  def update_output(value):
      return 'You have selected &quot;{}&quot;'.format(value)
  
  
  #Callback for submitting everything.
  @app.callback(Output('target', 'children'), Input('submit', 'n_clicks'))
  def callback(n_clicks):
      if ('n_clicks' != 0):
           return f'The result of the submission {n_clicks}'
  </code></pre>
  <p>I just need to be able to upload the file, choose a category(Drop down list), and then be able to submit by knowing the output which are the inputs of the upload and category(Dropdown list). Does anyone know how to do this?</p>
  <p>I have the file list here where one can choose a category from the dropdown and press to submit which the calculations corresponding would then display a graph. My calculations are not displayed here as I need a way to use them for the app.callback to perform the calculations and display a graph from the function of my calculations which would be the output for my submit button.</p>
  <p><a href="https://i.stack.imgur.com/LyhUD.png" rel="nofollow noreferrer">My Dashboard</a></p>