title: Python/Flask - Display image from file input
body: <p>Plain and simple, I'm aiming to have a user input their name, and select an image from the file input. With some help with my previous question, I was able to get the name to carry over to the next page, but I'm unable to get a selected image to display.</p>
  <p>Right now, when filled out, the name and image file name are provided. Hoping to get the image file to actually display the image.</p>
  <p>Home page...
  <a href="https://i.stack.imgur.com/K2Bll.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K2Bll.png" alt="Home Page" /></a></p>
  <p>Display page...
  <a href="https://i.stack.imgur.com/zjpAk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zjpAk.png" alt="Result Page" /></a></p>
  <p>Here is my current code:</p>
  <p>Home.html</p>
  <pre><code>{% extends 'base.html' %}
  {% block head %}
  &lt;title&gt;Home Page&lt;/title&gt;
  {% endblock %}
  {% block body %}
  
    &lt;div class=&quot;content-container&quot;&gt;
      &lt;form action=&quot;{{ url_for('result') }}&quot; method=&quot;post&quot;&gt;
        &lt;h2&gt;Input your name:&lt;/h2&gt;
        &lt;input type=&quot;text&quot; class=&quot;user-input user mb-3&quot; name=&quot;user&quot;&gt;
        &lt;h2&gt;Select your image:&lt;/h2&gt;
        &lt;input type=&quot;file&quot; accept=&quot;image/*&quot; class=&quot;form-control-file&quot;
               id=&quot;formControlFile1&quot; name=&quot;image&quot;&gt;
        &lt;input class=&quot;btn btn-outline-primary&quot; type=&quot;submit&quot; value=&quot;Submit&quot;&gt;
      &lt;/form&gt;
    &lt;/div&gt;
  
  {% endblock %}
  </code></pre>
  <p>Result.html</p>
  <pre><code>{% extends 'base.html' %}
  {% block head %}
  &lt;title&gt;Result Page&lt;/title&gt;
  {% endblock %}
  {% block body %}
  
    &lt;div class=&quot;content-container&quot;&gt;
      &lt;h2&gt;{{ name }}&lt;/h2&gt;
      &lt;h2&gt;{{ image }}&lt;/h2&gt;
    &lt;/div&gt;
  
  {% endblock %}
  </code></pre>
  <p>Main.py</p>
  <pre><code>from flask import Flask, render_template, request, url_for, redirect
  
  app = Flask(__name__)
  
  
  @app.route('/', methods=['GET', 'POST'])
  def home():
      if request.method == 'POST':
          user = request.form[&quot;user&quot;]
          image = request.form[&quot;image&quot;]
          return redirect(url_for('result', name=user, image=image))
      return render_template('home.html')
  
  
  @app.route(&quot;/result&quot;, methods=['GET', 'POST'])
  def result():
      name = request.form.get('user')
      image = request.form.get('image')
      return render_template(&quot;result.html&quot;, name=name, image=image)
  
  
  if __name__ == &quot;__main__&quot;:
      app.run()
  
  </code></pre>
  <p>So, yeah, hopefully I explained that easy enough. User inputs name, selects image, and the goal is for the name to show and image to display on the result page. Thanks to anyone that can provide this lowly soul with guidance.</p>