title: Uploaded Image file not being saved to the directory( flask python)
body: <p>So, I am trying to save this user uploaded image file into my directory using flask. Everything works fine except the image is not getting saved.</p>
  <p>Here is my code snippet:</p>
  <pre><code>import os
  from flask import Flask, flash, request, redirect, url_for,render_template
  from werkzeug.utils import secure_filename
  
  UPLOAD_FOLDER = './static/uploads'
  ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'}
  
  app = Flask(__name__)
  
  app.config['SECRET_KEY'] = 'mysecretkey'
  app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
  
  def allowed_file(filename):
      return '.' in filename and \
             filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
  
  @app.route('/', methods=['GET', 'POST'])
  def upload_file():
      if request.method == 'POST':
          # check if the post request has the file part
          if 'file' not in request.files:
              flash('No file part')
              return redirect(request.url)
          file = request.files['file']
          # if user does not select file, browser also
          # submit an empty part without filename
          if file.filename == '':
              flash('No selected file')
              return redirect(request.url)
          if file and allowed_file(file.filename):
              filename = secure_filename(file.filename)
              file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
              print(&quot;File is saved successfully in the uploads folder!!&quot;)
              # return redirect(url_for('upload_file',
              #                         filename=filename))
      return render_template('index.html')
  
  if __name__ == '__main__':
      app.run(debug=True)    
  </code></pre>
  <p>Here is the HTML code:</p>
  <pre><code>&lt;h1&gt;Uploads&lt;/h1&gt;
  
  &lt;form action=&quot;&quot; method=&quot;POST&quot; enctype=&quot;multipart/form-data&quot;&gt;
  
      &lt;input type=&quot;file&quot; name=&quot;upload&quot;&gt;
      &lt;input type=&quot;submit&quot; value=&quot;upload&quot;&gt;
  
  &lt;/form&gt;
  </code></pre>
  <p>There are no errors. Please help me know what's wrong.</p>
  <p>(P.S: Please ignore the open secret key, I will secure it later :'))</p>