title: Base64 encode file while uploading in flask
body: <p>Have you any idea base64 encode of file in flask?</p>
  
  <p>I have tried ...</p>
  
  <pre><code>import base64
  
  
  @users_blueprint.route('/add-source', methods=['GET', 'POST'])
  @ensure_authenticated
  @user_authenticated
  
  def add_user_resource():
      file = request.files['file']
  
      #file = request.files['file'].filename
  
      with open(file, "rb") as imageFile:
          str = base64.b64encode(imageFile.read())
          print str  
      return str
  </code></pre>
  
  <p>I got error
  <strong>#FileNotFoundError: [Errno 2] No such file or directory: 'Tulips.jpg'</strong></p>
  
  <p>any idea? Thank you in advance?</p>
  
  <p><a href="https://pastebin.com/nGubkfeY" rel="nofollow noreferrer">https://pastebin.com/nGubkfeY</a></p>